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 };
9+ use SimpleSAML \XML \TypedTextContentTrait ;
1210use SimpleSAML \XML \Type \Base64BinaryValue ;
1311
14- use function strval ;
15-
1612/**
17- * Empty shell class for testing Base64Binary elements.
13+ * Empty shell class for testing xs:base64Binary elements.
1814 *
1915 * @package simplesaml/xml-common
2016 */
2117final class Base64BinaryElement extends AbstractElement implements SchemaValidatableElementInterface
2218{
19+ use TypedTextContentTrait;
2320 use SchemaValidatableElementTrait;
2421
2522 /** @var string */
@@ -31,44 +28,11 @@ final class Base64BinaryElement extends AbstractElement implements SchemaValidat
3128 /** @var string */
3229 public const SCHEMA = 'tests/resources/schemas/deliberately-wrong-file.xsd ' ;
3330
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- }
31+ /** @var string */
32+ public const TEXTCONTENT_TYPE = AbstractElement::class; // Deliberately wrong class
5933
6034
6135 /**
62- * Create XML from this class
63- *
64- * @param \DOMElement|null $parent
65- * @return \DOMElement
36+ * NOTE: This class has some deliberately wrong values for testing purposes!!
6637 */
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- }
7438}
0 commit comments