44
55namespace SimpleSAML \Test \XML ;
66
7- use DOMElement ;
87use SimpleSAML \XML \AbstractElement ;
9- use SimpleSAML \XML \Assert \Assert ;
10- use SimpleSAML \XML \Exception \InvalidDOMElementException ;
118use SimpleSAML \XML \{SchemaValidatableElementInterface , SchemaValidatableElementTrait };
12- use SimpleSAML \XML \Type \Base64BinaryValue ;
13-
14- use function strval ;
9+ use SimpleSAML \XML \TypedTextContentTrait ;
1510
1611/**
17- * Empty shell class for testing Base64Binary elements.
12+ * Empty shell class for testing xs:base64Binary elements.
1813 *
1914 * @package simplesaml/xml-common
2015 */
2116final class Base64BinaryElement extends AbstractElement implements SchemaValidatableElementInterface
2217{
18+ use TypedTextContentTrait;
2319 use SchemaValidatableElementTrait;
2420
2521 /** @var string */
@@ -31,44 +27,11 @@ final class Base64BinaryElement extends AbstractElement implements SchemaValidat
3127 /** @var string */
3228 public const SCHEMA = 'tests/resources/schemas/deliberately-wrong-file.xsd ' ;
3329
34-
35- /**
36- * @param \SimpleSAML\XML\Type\Base64BinaryValue $content
37- */
38- public function __construct (
39- protected Base64BinaryValue $ content ,
40- ) {
41- }
42-
43-
44- /**
45- * Create a class from XML
46- *
47- * @param \DOMElement $xml
48- * @return static
49- */
50- public static function fromXML (DOMElement $ xml ): static
51- {
52- Assert::same ($ xml ->localName , static ::getLocalName (), InvalidDOMElementException::class);
53- Assert::same ($ xml ->namespaceURI , static ::NS , InvalidDOMElementException::class);
54-
55- $ text = Base64BinaryValue::fromString ($ xml ->textContent );
56-
57- return new static ($ text );
58- }
30+ /** @var string */
31+ public const TEXTCONTENT_TYPE = AbstractElement::class; // Deliberately wrong class
5932
6033
6134 /**
62- * Create XML from this class
63- *
64- * @param \DOMElement|null $parent
65- * @return \DOMElement
35+ * NOTE: This class has some deliberately wrong values for testing purposes!!
6636 */
67- public function toXML (?DOMElement $ parent = null ): DOMElement
68- {
69- $ e = $ this ->instantiateParentElement ($ parent );
70- $ e ->textContent = strval ($ this ->content );
71-
72- return $ e ;
73- }
7437}
0 commit comments