Skip to content

Commit

Permalink
Re-add element traits
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 16, 2025
1 parent d2b0100 commit caf6942
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 6 additions & 1 deletion tests/Utils/Base64BinaryElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!!
*/
}
11 changes: 6 additions & 5 deletions tests/XML/TypedTextContentTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit caf6942

Please sign in to comment.