Skip to content

Commit caf6942

Browse files
committed
Re-add element traits
1 parent d2b0100 commit caf6942

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

tests/Utils/Base64BinaryElement.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@ final class Base64BinaryElement extends AbstractElement implements SchemaValidat
2929
public const SCHEMA = 'tests/resources/schemas/deliberately-wrong-file.xsd';
3030

3131
/** @var string */
32-
public const TEXTCONTENT_TYPE = Base64BinaryValue::class;
32+
public const TEXTCONTENT_TYPE = AbstractElement::class; // Deliberately wrong class
33+
34+
35+
/**
36+
* NOTE: This class has some deliberately wrong values for testing purposes!!
37+
*/
3338
}

tests/XML/TypedTextContentTraitTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ public function testTypedContentPassesForBoolean(): void
4040
}
4141

4242

43-
public function testTypedContentForBase64Binary(): void
43+
public function testTypedContentFailsForWrongType(): void
4444
{
45-
$file = 'tests/resources/xml/ssp_Base64BinaryElement.xml';
45+
$file = 'tests/resources/xml/ssp_BooleanElement.xml';
4646
$chunk = DOMDocumentFactory::fromFile($file);
47+
$chunk->documentElement->textContent = 'not-a-boolean';
4748

48-
$stringElt = Base64BinaryElement::fromXML($chunk->documentElement);
49-
$this->assertInstanceOf(Base64BinaryElement::class, $stringElt);
49+
$this->expectException(SchemaViolationException::class);
50+
BooleanElement::fromXML($chunk->documentElement);
5051
}
5152

5253

53-
public function testTypedContentFailsForWrongType(): void
54+
public function testTypedContentFailsForWrongClass(): void
5455
{
5556
$file = 'tests/resources/xml/ssp_BooleanElement.xml';
5657
$chunk = DOMDocumentFactory::fromFile($file);

0 commit comments

Comments
 (0)