diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 34dc9dd..2fa0583 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -57,7 +57,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: ctype, dom, filter, intl, pcre, sodium, spl, xml tools: composer - ini-values: error_reporting=E_ALL + ini-values: display_errors=on, error_reporting=E_ALL coverage: pcov - name: Setup problem matchers for PHP diff --git a/src/SOAP11/Utils/XPath.php b/src/SOAP11/Utils/XPath.php index 3fe5d3c..c41f90c 100644 --- a/src/SOAP11/Utils/XPath.php +++ b/src/SOAP11/Utils/XPath.php @@ -4,8 +4,7 @@ namespace SimpleSAML\SOAP11\Utils; -use DOMNode; -use DOMXPath; +use Dom; use SimpleSAML\SOAP11\Constants as C; /** @@ -16,15 +15,15 @@ class XPath extends \SimpleSAML\XPath\XPath { /** - * Get a DOMXPath object that can be used to search for SAML elements. + * Get a Dom\XPath object that can be used to search for SAML elements. * - * @param \DOMNode $node The document to associate to the DOMXPath object. + * @param \Dom\Node $node The document to associate to the Dom\XPath object. * @param bool $autoregister Whether to auto-register all namespaces used in the document * - * @return \DOMXPath A DOMXPath object ready to use in the given document, with several + * @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several * saml-related namespaces already registered. */ - public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath + public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath { $xp = parent::getXPath($node, $autoregister); diff --git a/src/SOAP11/XML/Body.php b/src/SOAP11/XML/Body.php index 0ff3fed..df6f64d 100644 --- a/src/SOAP11/XML/Body.php +++ b/src/SOAP11/XML/Body.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP11\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP11\Assert\Assert; use SimpleSAML\SOAP11\Exception\ProtocolViolationException; use SimpleSAML\XML\ExtendableAttributesTrait; @@ -16,7 +16,7 @@ use function array_diff; use function array_filter; -use function array_pop; +use function array_last; use function array_values; /** @@ -61,7 +61,7 @@ public function __construct(array $children = [], array $namespacedAttributes = })); Assert::maxCount($fault, 1, ProtocolViolationException::class); - $this->setFault(array_pop($fault)); + $this->setFault(array_last($fault)); $this->setElements(array_diff($children, $fault)); $this->setAttributesNS($namespacedAttributes); } @@ -97,12 +97,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Body element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Body', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Body::NS, InvalidDOMElementException::class); @@ -117,9 +117,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Body to XML. * - * @param \DOMElement|null $parent The element we should add this Body to. + * @param \Dom\Element|null $parent The element we should add this Body to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP11/XML/Detail.php b/src/SOAP11/XML/Detail.php index b221f66..b8ff6cd 100644 --- a/src/SOAP11/XML/Detail.php +++ b/src/SOAP11/XML/Detail.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP11\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP11\Assert\Assert; use SimpleSAML\XML\AbstractElement; use SimpleSAML\XML\ExtendableAttributesTrait; @@ -61,12 +61,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Detail element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'detail', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class); @@ -81,9 +81,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Detail to XML. * - * @param \DOMElement|null $parent The element we should add this Detail to. + * @param \Dom\Element|null $parent The element we should add this Detail to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP11/XML/Envelope.php b/src/SOAP11/XML/Envelope.php index 3476918..8591757 100644 --- a/src/SOAP11/XML/Envelope.php +++ b/src/SOAP11/XML/Envelope.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP11\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP11\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -15,6 +15,8 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\XML\Constants\NS; +use function array_last; + /** * Class representing a SOAP-ENV:Envelope element. * @@ -74,12 +76,12 @@ public function getHeader(): ?Header /** * Convert XML into an Envelope element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Envelope', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Envelope::NS, InvalidDOMElementException::class); @@ -91,8 +93,8 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class); return new static( - array_pop($body), - empty($header) ? null : array_pop($header), + array_last($body), + array_last($header), self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -102,9 +104,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Envelope to XML. * - * @param \DOMElement|null $parent The element we should add this envelope to. + * @param \Dom\Element|null $parent The element we should add this envelope to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP11/XML/Fault.php b/src/SOAP11/XML/Fault.php index 2e7991c..b91be5b 100644 --- a/src/SOAP11/XML/Fault.php +++ b/src/SOAP11/XML/Fault.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP11\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP11\Assert\Assert; use SimpleSAML\XML\SchemaValidatableElementInterface; use SimpleSAML\XML\SchemaValidatableElementTrait; @@ -12,6 +12,8 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * Class representing a SOAP-ENV:Fault element. * @@ -78,12 +80,12 @@ public function getDetail(): ?Detail /** * Convert XML into an Fault element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Fault', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Fault::NS, InvalidDOMElementException::class); @@ -106,10 +108,10 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($detail, 1, 'Cannot process more than one detail element.', TooManyElementsException::class); return new self( - array_pop($faultCode), - array_pop($faultString), - array_pop($faultActor), - array_pop($detail), + array_last($faultCode), + array_last($faultString), + array_last($faultActor), + array_last($detail), ); } @@ -117,9 +119,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Fault to XML. * - * @param \DOMElement|null $parent The element we should add this fault to. + * @param \Dom\Element|null $parent The element we should add this fault to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP11/XML/Header.php b/src/SOAP11/XML/Header.php index e7efa5d..651931c 100644 --- a/src/SOAP11/XML/Header.php +++ b/src/SOAP11/XML/Header.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP11\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP11\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -57,12 +57,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Header element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Header', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Header::NS, InvalidDOMElementException::class); @@ -77,9 +77,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Header to XML. * - * @param \DOMElement|null $parent The element we should add this header to. + * @param \Dom\Element|null $parent The element we should add this header to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/Utils/XPath.php b/src/SOAP12/Utils/XPath.php index 42ab51c..0d22ccb 100644 --- a/src/SOAP12/Utils/XPath.php +++ b/src/SOAP12/Utils/XPath.php @@ -4,8 +4,7 @@ namespace SimpleSAML\SOAP12\Utils; -use DOMNode; -use DOMXPath; +use Dom; use SimpleSAML\SOAP12\Constants as C; /** @@ -16,15 +15,15 @@ class XPath extends \SimpleSAML\XPath\XPath { /** - * Get a DOMXPath object that can be used to search for SAML elements. + * Get a Dom\XPath object that can be used to search for SAML elements. * - * @param \DOMNode $node The document to associate to the DOMXPath object. + * @param \Dom\Node $node The document to associate to the Dom\XPath object. * @param bool $autoregister Whether to auto-register all namespaces used in the document * - * @return \DOMXPath A DOMXPath object ready to use in the given document, with several + * @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several * saml-related namespaces already registered. */ - public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath + public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath { $xp = parent::getXPath($node, $autoregister); diff --git a/src/SOAP12/XML/Body.php b/src/SOAP12/XML/Body.php index db8b2fc..cab030d 100644 --- a/src/SOAP12/XML/Body.php +++ b/src/SOAP12/XML/Body.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\SOAP12\Exception\ProtocolViolationException; use SimpleSAML\XML\ExtendableAttributesTrait; @@ -14,7 +14,7 @@ use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\XML\Constants\NS; -use function array_pop; +use function array_last; /** * Class representing a env:Body element. @@ -86,12 +86,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Body element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Body', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Body::NS, InvalidDOMElementException::class); @@ -104,7 +104,7 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($fault, 1, ProtocolViolationException::class); return new static( - array_pop($fault), + array_last($fault), self::getChildElementsFromXML($xml), self::getAttributesNSFromXML($xml), ); @@ -114,9 +114,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Body to XML. * - * @param \DOMElement|null $parent The element we should add this Body to. + * @param \Dom\Element|null $parent The element we should add this Body to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Code.php b/src/SOAP12/XML/Code.php index d0c5cc4..275f61a 100644 --- a/src/SOAP12/XML/Code.php +++ b/src/SOAP12/XML/Code.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; @@ -51,12 +51,12 @@ public function getSubcode(): ?Subcode /** * Convert XML into an Code element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Code', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Code::NS, InvalidDOMElementException::class); @@ -68,8 +68,8 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subcode, 1, 'Cannot process more than one Subcode element.', TooManyElementsException::class); return new static( - array_pop($value), - empty($subcode) ? null : array_pop($subcode), + array_last($value), + array_last($subcode), ); } @@ -77,9 +77,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Code to XML. * - * @param \DOMElement|null $parent The element we should add this code to. + * @param \Dom\Element|null $parent The element we should add this code to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Detail.php b/src/SOAP12/XML/Detail.php index 1852371..1030394 100644 --- a/src/SOAP12/XML/Detail.php +++ b/src/SOAP12/XML/Detail.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -54,12 +54,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Detail element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Detail', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Detail::NS, InvalidDOMElementException::class); @@ -74,9 +74,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Detail to XML. * - * @param \DOMElement|null $parent The element we should add this Detail to. + * @param \Dom\Element|null $parent The element we should add this Detail to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Envelope.php b/src/SOAP12/XML/Envelope.php index f057ccd..c628e02 100644 --- a/src/SOAP12/XML/Envelope.php +++ b/src/SOAP12/XML/Envelope.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\SchemaValidatableElementInterface; @@ -14,6 +14,8 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\XML\Constants\NS; +use function array_last; + /** * Class representing a env:Envelope element. * @@ -66,12 +68,12 @@ public function getHeader(): ?Header /** * Convert XML into an Envelope element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Envelope', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Envelope::NS, InvalidDOMElementException::class); @@ -83,8 +85,8 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($header, 1, 'Cannot process more than one Header element.', TooManyElementsException::class); return new static( - array_pop($body), - empty($header) ? null : array_pop($header), + array_last($body), + array_last($header), self::getAttributesNSFromXML($xml), ); } @@ -93,9 +95,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Envelope to XML. * - * @param \DOMElement|null $parent The element we should add this envelope to. + * @param \Dom\Element|null $parent The element we should add this envelope to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Fault.php b/src/SOAP12/XML/Fault.php index fe44c8b..ec8df81 100644 --- a/src/SOAP12/XML/Fault.php +++ b/src/SOAP12/XML/Fault.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\SchemaValidatableElementInterface; @@ -13,6 +13,8 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * Class representing a env:Fault element. * @@ -90,12 +92,12 @@ public function getDetail(): ?Detail /** * Convert XML into an Fault element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Fault', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Fault::NS, InvalidDOMElementException::class); @@ -116,11 +118,11 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($detail, 1, 'Cannot process more than one Detail element.', TooManyElementsException::class); return new self( - array_pop($code), - array_pop($reason), - empty($node) ? null : array_pop($node), - empty($role) ? null : array_pop($role), - empty($detail) ? null : array_pop($detail), + array_last($code), + array_last($reason), + array_last($node), + array_last($role), + array_last($detail), ); } @@ -128,9 +130,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Fault to XML. * - * @param \DOMElement|null $parent The element we should add this fault to. + * @param \Dom\Element|null $parent The element we should add this fault to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Header.php b/src/SOAP12/XML/Header.php index 73926e0..64561ce 100644 --- a/src/SOAP12/XML/Header.php +++ b/src/SOAP12/XML/Header.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -57,12 +57,12 @@ public function isEmptyElement(): bool /* * Convert XML into an Header element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Header', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Header::NS, InvalidDOMElementException::class); @@ -77,9 +77,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Header to XML. * - * @param \DOMElement|null $parent The element we should add this header to. + * @param \Dom\Element|null $parent The element we should add this header to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/NotUnderstood.php b/src/SOAP12/XML/NotUnderstood.php index 43449f6..56ea9de 100644 --- a/src/SOAP12/XML/NotUnderstood.php +++ b/src/SOAP12/XML/NotUnderstood.php @@ -4,9 +4,10 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\Attribute as XMLAttribute; +use SimpleSAML\XML\Constants as C; use SimpleSAML\XML\SchemaValidatableElementInterface; use SimpleSAML\XML\SchemaValidatableElementTrait; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -46,12 +47,12 @@ public function getQName(): QNameValue /* * Convert XML into a NotUnderstood element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'NotUnderstood', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -66,19 +67,22 @@ public static function fromXML(DOMElement $xml): static /** * Convert this NotUnderstood to XML. * - * @param \DOMElement|null $parent The element we should add this Body to. + * @param \Dom\Element|null $parent The element we should add this Body to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); - if (!$e->lookupPrefix($this->getQName()->getNamespaceURI()->getValue())) { - $namespace = new XMLAttribute( - 'http://www.w3.org/2000/xmlns/', - 'xmlns', - $this->getQName()->getNamespacePrefix()->getValue(), - $this->getQName()->getNamespaceURI(), - ); + $namespace = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + $this->getQName()->getNamespacePrefix()->getValue(), + $this->getQName()->getNamespaceURI(), + ); + + if ($parent !== null && !$parent->lookupPrefix($this->getQName()->getNamespacePrefix()->getValue())) { + $namespace->toXML($parent); + } elseif (!$e->lookupPrefix($this->getQName()->getNamespacePrefix()->getValue())) { $namespace->toXML($e); } diff --git a/src/SOAP12/XML/Reason.php b/src/SOAP12/XML/Reason.php index 586198c..7657c3a 100644 --- a/src/SOAP12/XML/Reason.php +++ b/src/SOAP12/XML/Reason.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\Constants as C; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -43,12 +43,12 @@ public function getText(): array /** * Convert XML into a Value * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Reason', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Reason::NS, InvalidDOMElementException::class); @@ -63,9 +63,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this element to XML. * - * @param \DOMElement|null $parent The element we should append this element to. + * @param \Dom\Element|null $parent The element we should append this element to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Subcode.php b/src/SOAP12/XML/Subcode.php index 21494bf..13749c7 100644 --- a/src/SOAP12/XML/Subcode.php +++ b/src/SOAP12/XML/Subcode.php @@ -4,12 +4,14 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * Class representing a env:Subcode element. * @@ -51,12 +53,12 @@ public function getSubcode(): ?Subcode /** * Convert XML into an Subcode element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Subcode', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Subcode::NS, InvalidDOMElementException::class); @@ -68,8 +70,8 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subcode, 1, 'Cannot process more than one Subcode element.', TooManyElementsException::class); return new static( - array_pop($value), - empty($subcode) ? null : array_pop($subcode), + array_last($value), + array_last($subcode), ); } @@ -77,9 +79,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Subcode to XML. * - * @param \DOMElement|null $parent The element we should add this subcode to. + * @param \Dom\Element|null $parent The element we should add this subcode to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/SupportedEnvelope.php b/src/SOAP12/XML/SupportedEnvelope.php index c39cffd..bef5b2d 100644 --- a/src/SOAP12/XML/SupportedEnvelope.php +++ b/src/SOAP12/XML/SupportedEnvelope.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\Attribute as XMLAttribute; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -43,12 +43,12 @@ public function getQName(): QNameValue /* * Convert XML into a SupportedEnvelope element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'SupportedEnvelope', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -63,9 +63,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this SupportedEnvelope to XML. * - * @param \DOMElement|null $parent The element we should add this Body to. + * @param \Dom\Element|null $parent The element we should add this Body to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SOAP12/XML/Text.php b/src/SOAP12/XML/Text.php index 20dd1df..5f8982a 100644 --- a/src/SOAP12/XML/Text.php +++ b/src/SOAP12/XML/Text.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\SOAP12\Constants as C; use SimpleSAML\XML\Type\LangValue; @@ -59,12 +59,12 @@ public function getContent(): StringValue /** * Convert XML into a env:Text element * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Text', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -84,9 +84,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Text element to XML. * - * @param \DOMElement|null $parent The element we should append this Text element to. + * @param \Dom\Element|null $parent The element we should append this Text element to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = strval($this->getContent()); diff --git a/src/SOAP12/XML/Upgrade.php b/src/SOAP12/XML/Upgrade.php index 58f2ea3..9472008 100644 --- a/src/SOAP12/XML/Upgrade.php +++ b/src/SOAP12/XML/Upgrade.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SOAP12\XML; -use DOMElement; +use Dom; use SimpleSAML\SOAP12\Assert\Assert; use SimpleSAML\XML\Constants as C; use SimpleSAML\XML\SchemaValidatableElementInterface; @@ -48,9 +48,9 @@ public function getSupportedEnvelope(): array /** * Convert this element to XML. * - * @param \DOMElement|null $parent The element we should append this element to. + * @param \Dom\Element|null $parent The element we should append this element to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); @@ -65,12 +65,12 @@ public function toXML(?DOMElement $parent = null): DOMElement /** * Convert XML into a Upgrade * - * @param \DOMElement $xml The XML element we should load + * @param \Dom\Element $xml The XML element we should load * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * If the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Upgrade', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Upgrade::NS, InvalidDOMElementException::class); diff --git a/tests/SOAP11/XML/BodyTest.php b/tests/SOAP11/XML/BodyTest.php index b9a99ea..82c073e 100644 --- a/tests/SOAP11/XML/BodyTest.php +++ b/tests/SOAP11/XML/BodyTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP11\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP11\Constants as C; @@ -38,7 +38,7 @@ final class BodyTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $BodyContent; + private static Dom\Element $BodyContent; /** @@ -66,10 +66,11 @@ public function testMarshalling(): void $body = new Body([new Chunk(self::$BodyContent)], [$domAttr]); $this->assertFalse($body->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($body), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($body); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP11/XML/DetailTest.php b/tests/SOAP11/XML/DetailTest.php index e47192f..64f3947 100644 --- a/tests/SOAP11/XML/DetailTest.php +++ b/tests/SOAP11/XML/DetailTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP11\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP11\XML\AbstractSoapElement; @@ -30,7 +30,7 @@ final class DetailTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $DetailContent; + private static Dom\Element $DetailContent; /** @@ -58,10 +58,11 @@ public function testMarshalling(): void $detail = new Detail([new Chunk(self::$DetailContent)], [$domAttr]); $this->assertFalse($detail->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($detail), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($detail); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP11/XML/EnvelopeTest.php b/tests/SOAP11/XML/EnvelopeTest.php index 3c3a928..add8d2b 100644 --- a/tests/SOAP11/XML/EnvelopeTest.php +++ b/tests/SOAP11/XML/EnvelopeTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP11\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP11\XML\AbstractSoapElement; @@ -34,11 +34,11 @@ final class EnvelopeTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $bodyContent; + private static Dom\Element $bodyContent; - private static DOMElement $headerContent; + private static Dom\Element $headerContent; - private static DOMElement $envelopeContent; + private static Dom\Element $envelopeContent; /** @@ -76,9 +76,10 @@ public function testMarshalling(): void $envelope = new Envelope($body, $header, [new Chunk(self::$envelopeContent)], [$domAttr]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($envelope), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($envelope); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP11/XML/FaultActorTest.php b/tests/SOAP11/XML/FaultActorTest.php index f206363..2b99ce2 100644 --- a/tests/SOAP11/XML/FaultActorTest.php +++ b/tests/SOAP11/XML/FaultActorTest.php @@ -44,9 +44,10 @@ public function testMarshalling(): void { $faultActor = FaultActor::fromString('urn:x-simplesamlphp:namespace'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($faultActor), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($faultActor); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP11/XML/FaultCodeTest.php b/tests/SOAP11/XML/FaultCodeTest.php index 22a75f7..10f480c 100644 --- a/tests/SOAP11/XML/FaultCodeTest.php +++ b/tests/SOAP11/XML/FaultCodeTest.php @@ -45,9 +45,10 @@ public function testMarshalling(): void { $faultCode = FaultCode::fromString('{' . C::NS_SOAP_ENV . '}env:Sender'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($faultCode), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($faultCode); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP11/XML/FaultStringTest.php b/tests/SOAP11/XML/FaultStringTest.php index 8a64967..c503181 100644 --- a/tests/SOAP11/XML/FaultStringTest.php +++ b/tests/SOAP11/XML/FaultStringTest.php @@ -44,9 +44,10 @@ public function testMarshalling(): void { $faultString = FaultString::fromString('Something went wrong'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($faultString), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($faultString); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP11/XML/FaultTest.php b/tests/SOAP11/XML/FaultTest.php index f117b9d..c541c25 100644 --- a/tests/SOAP11/XML/FaultTest.php +++ b/tests/SOAP11/XML/FaultTest.php @@ -61,9 +61,10 @@ public function testMarshalling(): void ]), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($fault), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($fault); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP11/XML/HeaderTest.php b/tests/SOAP11/XML/HeaderTest.php index d4b663d..f4151d2 100644 --- a/tests/SOAP11/XML/HeaderTest.php +++ b/tests/SOAP11/XML/HeaderTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP11\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP11\XML\AbstractSoapElement; @@ -32,7 +32,7 @@ final class HeaderTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $headerContent; + private static Dom\Element $headerContent; /** @@ -60,10 +60,11 @@ public function testMarshalling(): void $header = new Header([new Chunk(self::$headerContent)], [$domAttr]); $this->assertFalse($header->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($header), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($header); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP12/XML/BodyTest.php b/tests/SOAP12/XML/BodyTest.php index 49d3f03..59ddeb8 100644 --- a/tests/SOAP12/XML/BodyTest.php +++ b/tests/SOAP12/XML/BodyTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP12\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP12\Constants as C; @@ -41,7 +41,7 @@ final class BodyTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $BodyContent; + private static Dom\Element $BodyContent; /** @@ -69,10 +69,11 @@ public function testMarshalling(): void $body = new Body(null, [new Chunk(self::$BodyContent)], [$domAttr]); $this->assertFalse($body->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($body), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($body); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP12/XML/CodeTest.php b/tests/SOAP12/XML/CodeTest.php index d122335..f502197 100644 --- a/tests/SOAP12/XML/CodeTest.php +++ b/tests/SOAP12/XML/CodeTest.php @@ -53,9 +53,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($code), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($code); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/DetailTest.php b/tests/SOAP12/XML/DetailTest.php index 08ef0d9..2cf68f5 100644 --- a/tests/SOAP12/XML/DetailTest.php +++ b/tests/SOAP12/XML/DetailTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP12\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP12\XML\AbstractSoapElement; @@ -30,7 +30,7 @@ final class DetailTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $DetailContent; + private static Dom\Element $DetailContent; /** @@ -58,10 +58,11 @@ public function testMarshalling(): void $detail = new Detail([new Chunk(self::$DetailContent)], [$domAttr]); $this->assertFalse($detail->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($detail), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($detail); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP12/XML/EnvelopeTest.php b/tests/SOAP12/XML/EnvelopeTest.php index b901bfd..c601435 100644 --- a/tests/SOAP12/XML/EnvelopeTest.php +++ b/tests/SOAP12/XML/EnvelopeTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP12\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP12\XML\AbstractSoapElement; @@ -34,9 +34,9 @@ final class EnvelopeTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $bodyContent; + private static Dom\Element $bodyContent; - private static DOMElement $headerContent; + private static Dom\Element $headerContent; /** @@ -70,9 +70,10 @@ public function testMarshalling(): void $envelope = new Envelope($body, $header, [$domAttr]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($envelope), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($envelope); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/FaultTest.php b/tests/SOAP12/XML/FaultTest.php index 5e15496..6a38738 100644 --- a/tests/SOAP12/XML/FaultTest.php +++ b/tests/SOAP12/XML/FaultTest.php @@ -80,9 +80,10 @@ public function testMarshalling(): void ]), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($fault), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($fault); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/HeaderTest.php b/tests/SOAP12/XML/HeaderTest.php index 15caad2..7d5fe63 100644 --- a/tests/SOAP12/XML/HeaderTest.php +++ b/tests/SOAP12/XML/HeaderTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SOAP12\XML; -use DOMElement; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\SOAP12\XML\AbstractSoapElement; @@ -32,7 +32,7 @@ final class HeaderTest extends TestCase use SerializableElementTestTrait; - private static DOMElement $headerContent; + private static Dom\Element $headerContent; /** @@ -60,10 +60,11 @@ public function testMarshalling(): void $header = new Header([new Chunk(self::$headerContent)], [$domAttr]); $this->assertFalse($header->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($header), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($header); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/SOAP12/XML/NodeTest.php b/tests/SOAP12/XML/NodeTest.php index 249a3d9..f291a9e 100644 --- a/tests/SOAP12/XML/NodeTest.php +++ b/tests/SOAP12/XML/NodeTest.php @@ -44,9 +44,10 @@ public function testMarshalling(): void { $node = Node::fromString('urn:x-simplesamlphp:namespace'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($node), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($node); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/NotUnderstoodTest.php b/tests/SOAP12/XML/NotUnderstoodTest.php index 403bd49..568a5b0 100644 --- a/tests/SOAP12/XML/NotUnderstoodTest.php +++ b/tests/SOAP12/XML/NotUnderstoodTest.php @@ -49,9 +49,10 @@ public function testMarshalling(): void QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($notUnderstood), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($notUnderstood); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/ReasonTest.php b/tests/SOAP12/XML/ReasonTest.php index dcc4354..401c23b 100644 --- a/tests/SOAP12/XML/ReasonTest.php +++ b/tests/SOAP12/XML/ReasonTest.php @@ -50,9 +50,10 @@ public function testMarshalling(): void new Text(LangValue::fromString('nl'), StringValue::fromString('Het is stuk')), ]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($reason), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($reason); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/RoleTest.php b/tests/SOAP12/XML/RoleTest.php index 7daaff9..9fdc9c0 100644 --- a/tests/SOAP12/XML/RoleTest.php +++ b/tests/SOAP12/XML/RoleTest.php @@ -44,9 +44,10 @@ public function testMarshalling(): void { $role = Role::fromString('urn:x-simplesamlphp:namespace'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($role), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($role); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/SubcodeTest.php b/tests/SOAP12/XML/SubcodeTest.php index fb5724b..642454e 100644 --- a/tests/SOAP12/XML/SubcodeTest.php +++ b/tests/SOAP12/XML/SubcodeTest.php @@ -50,9 +50,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($subcode), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($subcode); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/SupportedEnvelopeTest.php b/tests/SOAP12/XML/SupportedEnvelopeTest.php index 0622d9b..7ea219b 100644 --- a/tests/SOAP12/XML/SupportedEnvelopeTest.php +++ b/tests/SOAP12/XML/SupportedEnvelopeTest.php @@ -47,9 +47,10 @@ public function testMarshalling(): void QNameValue::fromString('{urn:x-simplesamlphp:namespace}ssp:Chunk'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($supportedEnvelope), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($supportedEnvelope); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/TextTest.php b/tests/SOAP12/XML/TextTest.php index a7218be..4345a19 100644 --- a/tests/SOAP12/XML/TextTest.php +++ b/tests/SOAP12/XML/TextTest.php @@ -49,9 +49,10 @@ public function testMarshalling(): void StringValue::fromString('It\'s broken'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($text), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($text); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/UpgradeTest.php b/tests/SOAP12/XML/UpgradeTest.php index 0c7b5df..045f375 100644 --- a/tests/SOAP12/XML/UpgradeTest.php +++ b/tests/SOAP12/XML/UpgradeTest.php @@ -50,9 +50,10 @@ public function testMarshalling(): void new SupportedEnvelope(QNameValue::fromString('{' . SupportedEnvelope::NS . '}env:SupportedEnvelope')), ]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($upgrade), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($upgrade); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/SOAP12/XML/ValueTest.php b/tests/SOAP12/XML/ValueTest.php index d2f1da8..8e55279 100644 --- a/tests/SOAP12/XML/ValueTest.php +++ b/tests/SOAP12/XML/ValueTest.php @@ -45,9 +45,10 @@ public function testMarshalling(): void { $value = Value::fromString('{' . C::NS_SOAP_ENV . '}env:Sender'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($value), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($value); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/resources/xml/env/200305/Subcode.xml b/tests/resources/xml/env/200305/Subcode.xml index a98ae15..4e25fbf 100644 --- a/tests/resources/xml/env/200305/Subcode.xml +++ b/tests/resources/xml/env/200305/Subcode.xml @@ -1,6 +1,6 @@ - + m:SomethingNotFromSpec - m:MessageTimeout + m:MessageTimeout