From caf69423ebbde14661dbc4edacf0ebc1959a0b8d Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 16 Jan 2025 18:39:42 +0100 Subject: [PATCH] Re-add element traits --- tests/Utils/Base64BinaryElement.php | 7 ++++++- tests/XML/TypedTextContentTraitTest.php | 11 ++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/Utils/Base64BinaryElement.php b/tests/Utils/Base64BinaryElement.php index 4e94b6f..b52b7e8 100644 --- a/tests/Utils/Base64BinaryElement.php +++ b/tests/Utils/Base64BinaryElement.php @@ -29,5 +29,10 @@ final class Base64BinaryElement extends AbstractElement implements SchemaValidat public const SCHEMA = 'tests/resources/schemas/deliberately-wrong-file.xsd'; /** @var string */ - public const TEXTCONTENT_TYPE = Base64BinaryValue::class; + public const TEXTCONTENT_TYPE = AbstractElement::class; // Deliberately wrong class + + + /** + * NOTE: This class has some deliberately wrong values for testing purposes!! + */ } diff --git a/tests/XML/TypedTextContentTraitTest.php b/tests/XML/TypedTextContentTraitTest.php index 9158a75..cc7ee02 100644 --- a/tests/XML/TypedTextContentTraitTest.php +++ b/tests/XML/TypedTextContentTraitTest.php @@ -40,17 +40,18 @@ public function testTypedContentPassesForBoolean(): void } - public function testTypedContentForBase64Binary(): void + public function testTypedContentFailsForWrongType(): void { - $file = 'tests/resources/xml/ssp_Base64BinaryElement.xml'; + $file = 'tests/resources/xml/ssp_BooleanElement.xml'; $chunk = DOMDocumentFactory::fromFile($file); + $chunk->documentElement->textContent = 'not-a-boolean'; - $stringElt = Base64BinaryElement::fromXML($chunk->documentElement); - $this->assertInstanceOf(Base64BinaryElement::class, $stringElt); + $this->expectException(SchemaViolationException::class); + BooleanElement::fromXML($chunk->documentElement); } - public function testTypedContentFailsForWrongType(): void + public function testTypedContentFailsForWrongClass(): void { $file = 'tests/resources/xml/ssp_BooleanElement.xml'; $chunk = DOMDocumentFactory::fromFile($file);