diff --git a/composer.json b/composer.json
index 138e7b4..110202e 100644
--- a/composer.json
+++ b/composer.json
@@ -14,10 +14,10 @@
"ext-dom": "*",
"simplesamlphp/assert": "~2.0",
- "simplesamlphp/xml-common": "~2.8",
- "simplesamlphp/xml-ws-addressing": "~1.3",
- "simplesamlphp/xml-ws-policy": "~1.3",
- "simplesamlphp/xml-wss-core": "~1.4"
+ "simplesamlphp/xml-common": "dev-feature/dom-migration-php84",
+ "simplesamlphp/xml-ws-addressing": "dev-feature/dom-migration-php84",
+ "simplesamlphp/xml-ws-policy": "dev-feature/dom-migration-php84",
+ "simplesamlphp/xml-wss-core": "dev-feature/dom-migration-php84"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "~1.11"
diff --git a/src/TestUtils/sp_200507/NestedPolicyTypeTestTrait.php b/src/TestUtils/sp_200507/NestedPolicyTypeTestTrait.php
index a294a4e..a7d3a12 100644
--- a/src/TestUtils/sp_200507/NestedPolicyTypeTestTrait.php
+++ b/src/TestUtils/sp_200507/NestedPolicyTypeTestTrait.php
@@ -26,9 +26,10 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$policy, static::$some], [static::$attr]);
- $this->assertEquals(
- static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
- strval($np),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/src/TestUtils/sp_200702/NestedPolicyTypeTestTrait.php b/src/TestUtils/sp_200702/NestedPolicyTypeTestTrait.php
index cc3d80c..d53d9b9 100644
--- a/src/TestUtils/sp_200702/NestedPolicyTypeTestTrait.php
+++ b/src/TestUtils/sp_200702/NestedPolicyTypeTestTrait.php
@@ -29,10 +29,11 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$chunk], [static::$attr]);
- $this->assertEquals(
- static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
- strval($np),
- );
+ $expectedXml = static::$xmlRepresentation->saveXml(static::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -55,10 +56,11 @@ public function testMarshallingWithoutNSAttr(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = new static::$testedClass([static::$chunk]);
- $this->assertEquals(
- $xmlRepresentation->saveXML($xmlRepresentation->documentElement),
- strval($np),
- );
+ $expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -75,12 +77,13 @@ public function testMarshallingWithoutChildren(): void
$xmlRepresentation = DOMDocumentFactory::fromString($xml);
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $qns */
- $qns = new static::$testedClass([], [static::$attr]);
+ $np = new static::$testedClass([], [static::$attr]);
- $this->assertEquals(
- $xmlRepresentation->saveXML($xmlRepresentation->documentElement),
- strval($qns),
- );
+ $expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -127,10 +130,11 @@ public function testUnmarshallingWithoutNSAttr(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = static::$testedClass::fromXML($xmlRepresentation->documentElement);
- $this->assertEquals(
- $xmlRepresentation->saveXML($xmlRepresentation->documentElement),
- strval($np),
- );
+ $expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -150,9 +154,10 @@ public function testUnmarshallingWithoutChildren(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractNestedPolicyType $np */
$np = static::$testedClass::fromXML($xmlRepresentation->documentElement);
- $this->assertEquals(
- $xmlRepresentation->saveXML($xmlRepresentation->documentElement),
- strval($np),
- );
+ $expectedXml = $xmlRepresentation->saveXml($xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($np);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/src/Utils/XPath.php b/src/Utils/XPath.php
index 5db76dc..4d046b3 100644
--- a/src/Utils/XPath.php
+++ b/src/Utils/XPath.php
@@ -4,8 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\Utils;
-use DOMNode;
-use DOMXPath;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Constants as C;
/**
@@ -16,15 +15,15 @@
class XPath extends \SimpleSAML\XPath\XPath
{
/*
- * Get a DOMXPath object that can be used to search for WS Security elements.
+ * Get a Dom\XPath object that can be used to search for WS Security 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
* ws-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/XML/sp_200507/AbstractEmptyType.php b/src/XML/sp_200507/AbstractEmptyType.php
index c97b01d..e262a0a 100644
--- a/src/XML/sp_200507/AbstractEmptyType.php
+++ b/src/XML/sp_200507/AbstractEmptyType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -30,12 +30,12 @@ final public function __construct()
*
* Note: this method cannot be used when extending this class, if the constructor has a different signature.
*
- * @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -53,7 +53,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
return $this->instantiateParentElement($parent);
}
diff --git a/src/XML/sp_200507/AbstractHeaderType.php b/src/XML/sp_200507/AbstractHeaderType.php
index f3e530c..098f850 100644
--- a/src/XML/sp_200507/AbstractHeaderType.php
+++ b/src/XML/sp_200507/AbstractHeaderType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -77,12 +77,12 @@ public function getNamespace(): AnyURIValue
*
* Note: this method cannot be used when extending this class, if the constructor has a different signature.
*
- * @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -95,9 +95,10 @@ public static function fromXML(DOMElement $xml): static
$namespacedAttributes = self::getAttributesNSFromXML($xml);
$namespace = self::getAttribute($xml, 'Namespace', AnyURIValue::class);
+ $name = $xml->getAttribute('Name');
return new static(
$namespace,
- $xml->hasAttribute('Name') ? QNameValue::fromString($xml->getAttribute('Name')) : null,
+ ($name !== null) ? QNameValue::fromString($name) : null,
$namespacedAttributes,
);
}
@@ -106,7 +107,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractHttpsTokenType.php b/src/XML/sp_200507/AbstractHttpsTokenType.php
index df44b51..134684f 100644
--- a/src/XML/sp_200507/AbstractHttpsTokenType.php
+++ b/src/XML/sp_200507/AbstractHttpsTokenType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -68,12 +68,12 @@ public function getRequireClientCertificate(): BooleanValue
/**
* Initialize an HttpsTokenType.
*
- * @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -94,7 +94,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractIssuedTokenType.php b/src/XML/sp_200507/AbstractIssuedTokenType.php
index eea5279..b5aa612 100644
--- a/src/XML/sp_200507/AbstractIssuedTokenType.php
+++ b/src/XML/sp_200507/AbstractIssuedTokenType.php
@@ -4,9 +4,8 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
-use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\Type\IncludeTokenValue;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -88,7 +87,7 @@ public function getRequestSecurityTokenTemplate(): RequestSecurityTokenTemplate
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -116,7 +115,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractNestedPolicyType.php b/src/XML/sp_200507/AbstractNestedPolicyType.php
index a05b211..97869e5 100644
--- a/src/XML/sp_200507/AbstractNestedPolicyType.php
+++ b/src/XML/sp_200507/AbstractNestedPolicyType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -50,7 +50,7 @@ final public function __construct(
* @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, static::getLocalName(), InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -65,7 +65,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this AbstractNestedPolicyType to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractQNameAssertionType.php b/src/XML/sp_200507/AbstractQNameAssertionType.php
index 8bd6db8..9895704 100644
--- a/src/XML/sp_200507/AbstractQNameAssertionType.php
+++ b/src/XML/sp_200507/AbstractQNameAssertionType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -46,7 +46,7 @@ final public function __construct(
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -64,7 +64,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractRequestSecurityTokenTemplateType.php b/src/XML/sp_200507/AbstractRequestSecurityTokenTemplateType.php
index 786adfe..97b5743 100644
--- a/src/XML/sp_200507/AbstractRequestSecurityTokenTemplateType.php
+++ b/src/XML/sp_200507/AbstractRequestSecurityTokenTemplateType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -82,7 +82,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -107,10 +107,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.
- * @return \DOMElement
+ * @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/XML/sp_200507/AbstractSePartsType.php b/src/XML/sp_200507/AbstractSePartsType.php
index 4e9b553..8564904 100644
--- a/src/XML/sp_200507/AbstractSePartsType.php
+++ b/src/XML/sp_200507/AbstractSePartsType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -94,7 +94,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -121,7 +121,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractSecureConversationTokenType.php b/src/XML/sp_200507/AbstractSecureConversationTokenType.php
index e076a1e..80d64ff 100644
--- a/src/XML/sp_200507/AbstractSecureConversationTokenType.php
+++ b/src/XML/sp_200507/AbstractSecureConversationTokenType.php
@@ -4,9 +4,8 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
-use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\Type\IncludeTokenValue;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -82,7 +81,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -105,7 +104,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractSerElementsType.php b/src/XML/sp_200507/AbstractSerElementsType.php
index 0d5c352..f19fd93 100644
--- a/src/XML/sp_200507/AbstractSerElementsType.php
+++ b/src/XML/sp_200507/AbstractSerElementsType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -89,7 +89,7 @@ public function getXPathVersion(): ?AnyURIValue
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -111,7 +111,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractSpnegoContextTokenType.php b/src/XML/sp_200507/AbstractSpnegoContextTokenType.php
index 9fb3f35..cc486aa 100644
--- a/src/XML/sp_200507/AbstractSpnegoContextTokenType.php
+++ b/src/XML/sp_200507/AbstractSpnegoContextTokenType.php
@@ -4,9 +4,8 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
-use SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\Type\IncludeTokenValue;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -82,7 +81,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -105,7 +104,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/AbstractTokenAssertionType.php b/src/XML/sp_200507/AbstractTokenAssertionType.php
index 10f06aa..4f780e8 100644
--- a/src/XML/sp_200507/AbstractTokenAssertionType.php
+++ b/src/XML/sp_200507/AbstractTokenAssertionType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -64,7 +64,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200507/XPath.php b/src/XML/sp_200507/XPath.php
index 48d297f..77eddf6 100644
--- a/src/XML/sp_200507/XPath.php
+++ b/src/XML/sp_200507/XPath.php
@@ -4,8 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMNodeList;
-use DOMXPath;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TypedTextContentTrait;
@@ -31,8 +30,8 @@ final class XPath extends AbstractSpElement
*/
protected function validateContent(string $content): void
{
- $dom = new DOMXPath(DOMDocumentFactory::create());
+ $dom = new Dom\XPath(DOMDocumentFactory::create());
$result = $dom->evaluate($content);
- Assert::isInstanceOf($result, DOMNodeList::class);
+ Assert::isInstanceOf($result, Dom\NodeList::class);
}
}
diff --git a/src/XML/sp_200702/AbstractEmptyType.php b/src/XML/sp_200702/AbstractEmptyType.php
index a5e8d70..cdb4383 100644
--- a/src/XML/sp_200702/AbstractEmptyType.php
+++ b/src/XML/sp_200702/AbstractEmptyType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -33,7 +33,7 @@ final public function __construct()
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -51,7 +51,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
return $this->instantiateParentElement($parent);
}
diff --git a/src/XML/sp_200702/AbstractHeaderType.php b/src/XML/sp_200702/AbstractHeaderType.php
index 9e52484..4500c6b 100644
--- a/src/XML/sp_200702/AbstractHeaderType.php
+++ b/src/XML/sp_200702/AbstractHeaderType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -80,7 +80,7 @@ public function getNamespace(): AnyURIValue
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -93,9 +93,10 @@ public static function fromXML(DOMElement $xml): static
$namespacedAttributes = self::getAttributesNSFromXML($xml);
$namespace = self::getAttribute($xml, 'Namespace', AnyURIValue::class);
+ $name = $xml->getAttribute('Name');
return new static(
$namespace,
- $xml->hasAttribute('Name') ? QNameValue::fromString($xml->getAttribute('Name')) : null,
+ ($name !== null) ? QNameValue::fromString($name) : null,
$namespacedAttributes,
);
}
@@ -104,7 +105,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractIssuedTokenType.php b/src/XML/sp_200702/AbstractIssuedTokenType.php
index 0c9ac80..25e4d2d 100644
--- a/src/XML/sp_200702/AbstractIssuedTokenType.php
+++ b/src/XML/sp_200702/AbstractIssuedTokenType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -89,7 +89,7 @@ public function getRequestSecurityTokenTemplate(): RequestSecurityTokenTemplate
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -119,7 +119,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractKeyValueTokenType.php b/src/XML/sp_200702/AbstractKeyValueTokenType.php
index 7acdbe2..80d09fc 100644
--- a/src/XML/sp_200702/AbstractKeyValueTokenType.php
+++ b/src/XML/sp_200702/AbstractKeyValueTokenType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -64,7 +64,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractNestedPolicyType.php b/src/XML/sp_200702/AbstractNestedPolicyType.php
index c811ba3..03c3ffc 100644
--- a/src/XML/sp_200702/AbstractNestedPolicyType.php
+++ b/src/XML/sp_200702/AbstractNestedPolicyType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -58,7 +58,7 @@ public function isEmptyElement(): bool
* @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, static::getLocalName(), InvalidDOMElementException::class);
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -73,7 +73,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this AbstractNestedPolicyType to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractQNameAssertionType.php b/src/XML/sp_200702/AbstractQNameAssertionType.php
index 1a5b769..a6201d6 100644
--- a/src/XML/sp_200702/AbstractQNameAssertionType.php
+++ b/src/XML/sp_200702/AbstractQNameAssertionType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
@@ -46,7 +46,7 @@ final public function __construct(
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -64,7 +64,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractReqPartsType.php b/src/XML/sp_200702/AbstractReqPartsType.php
index e3634bd..cd47cf0 100644
--- a/src/XML/sp_200702/AbstractReqPartsType.php
+++ b/src/XML/sp_200702/AbstractReqPartsType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -79,7 +79,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -104,7 +104,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractRequestSecurityTokenTemplateType.php b/src/XML/sp_200702/AbstractRequestSecurityTokenTemplateType.php
index 5a87e23..585a1d2 100644
--- a/src/XML/sp_200702/AbstractRequestSecurityTokenTemplateType.php
+++ b/src/XML/sp_200702/AbstractRequestSecurityTokenTemplateType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -84,7 +84,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -109,7 +109,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractSePartsType.php b/src/XML/sp_200702/AbstractSePartsType.php
index e654319..f91c202 100644
--- a/src/XML/sp_200702/AbstractSePartsType.php
+++ b/src/XML/sp_200702/AbstractSePartsType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -108,7 +108,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -138,7 +138,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractSecureConversationTokenType.php b/src/XML/sp_200702/AbstractSecureConversationTokenType.php
index 99068d0..29ddbbc 100644
--- a/src/XML/sp_200702/AbstractSecureConversationTokenType.php
+++ b/src/XML/sp_200702/AbstractSecureConversationTokenType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -83,7 +83,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -108,7 +108,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractSerElementsType.php b/src/XML/sp_200702/AbstractSerElementsType.php
index 7da71b1..ed2ac46 100644
--- a/src/XML/sp_200702/AbstractSerElementsType.php
+++ b/src/XML/sp_200702/AbstractSerElementsType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -89,7 +89,7 @@ public function getXPathVersion(): ?AnyURIValue
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -99,11 +99,10 @@ public static function fromXML(DOMElement $xml): static
InvalidDOMElementException::class,
);
+ $version = $xml->getAttributeNS(self::NS, 'XPathVersion');
return new static(
XPath::getChildrenOfClass($xml),
- $xml->hasAttributeNS(self::NS, 'XPathVersion')
- ? AnyURIValue::fromString($xml->getAttributeNS(self::NS, 'XPathVersion'))
- : null,
+ ($version !== null) ? AnyURIValue::fromString($version) : null,
self::getChildElementsFromXML($xml),
self::getAttributesNSFromXML($xml),
);
@@ -113,7 +112,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractSpnegoContextTokenType.php b/src/XML/sp_200702/AbstractSpnegoContextTokenType.php
index 57b644f..28a4e8d 100644
--- a/src/XML/sp_200702/AbstractSpnegoContextTokenType.php
+++ b/src/XML/sp_200702/AbstractSpnegoContextTokenType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -83,7 +83,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -108,7 +108,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/AbstractTokenAssertionType.php b/src/XML/sp_200702/AbstractTokenAssertionType.php
index f564f5a..54b8dd3 100644
--- a/src/XML/sp_200702/AbstractTokenAssertionType.php
+++ b/src/XML/sp_200702/AbstractTokenAssertionType.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
@@ -64,7 +64,7 @@ public function isEmptyElement(): bool
* @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
{
$qualifiedName = static::getClassName(static::class);
Assert::eq(
@@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this element to XML.
*/
- public function toXML(?DOMElement $parent = null): DOMElement
+ public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);
diff --git a/src/XML/sp_200702/XPath.php b/src/XML/sp_200702/XPath.php
index 62a765a..2e1718a 100644
--- a/src/XML/sp_200702/XPath.php
+++ b/src/XML/sp_200702/XPath.php
@@ -4,8 +4,7 @@
namespace SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMNodeList;
-use DOMXPath;
+use Dom;
use SimpleSAML\WebServices\SecurityPolicy\Assert\Assert;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TypedTextContentTrait;
@@ -31,8 +30,8 @@ final class XPath extends AbstractSpElement
*/
protected function validateContent(string $content): void
{
- $dom = new DOMXPath(DOMDocumentFactory::create());
+ $dom = new Dom\XPath(DOMDocumentFactory::create());
$result = $dom->evaluate($content);
- Assert::isInstanceOf($result, DOMNodeList::class);
+ Assert::isInstanceOf($result, Dom\NodeList::class);
}
}
diff --git a/tests/SecurityPolicy/XML/mssp/RsaTokenTest.php b/tests/SecurityPolicy/XML/mssp/RsaTokenTest.php
index 8b1ce3a..5be6b5f 100644
--- a/tests/SecurityPolicy/XML/mssp/RsaTokenTest.php
+++ b/tests/SecurityPolicy/XML/mssp/RsaTokenTest.php
@@ -79,9 +79,10 @@ public function testMarshalling(): void
)->documentElement);
$rsaToken = new RsaToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($rsaToken),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($rsaToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/mssp/SslContextTokenTest.php b/tests/SecurityPolicy/XML/mssp/SslContextTokenTest.php
index 7c2e7aa..eed4d94 100644
--- a/tests/SecurityPolicy/XML/mssp/SslContextTokenTest.php
+++ b/tests/SecurityPolicy/XML/mssp/SslContextTokenTest.php
@@ -79,9 +79,10 @@ public function testMarshalling(): void
)->documentElement);
$sslContextToken = new SslContextToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($sslContextToken),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($sslContextToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/BodyTest.php b/tests/SecurityPolicy/XML/sp_200507/BodyTest.php
index e2e38a2..54ccceb 100644
--- a/tests/SecurityPolicy/XML/sp_200507/BodyTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/BodyTest.php
@@ -51,9 +51,10 @@ public function testMarshalling(): void
{
$body = new Body();
- $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/SecurityPolicy/XML/sp_200507/EncryptedElementsTest.php b/tests/SecurityPolicy/XML/sp_200507/EncryptedElementsTest.php
index a4706a2..854f102 100644
--- a/tests/SecurityPolicy/XML/sp_200507/EncryptedElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/EncryptedElementsTest.php
@@ -50,9 +50,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a EncryptedElements from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -66,33 +70,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$attr],
);
- $encryptedElementsElement = $encryptedElements->toXML();
- // Test for an XPath
- $xpCache = XMLXPath::getXPath($encryptedElementsElement);
- $encryptedElementsElements = XMLXPath::xpQuery($encryptedElementsElement, './sp:XPath', $xpCache);
- $this->assertCount(1, $encryptedElementsElements);
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($encryptedElements);
- // Test ordering of EncryptedElements contents
- /** @var \DOMElement[] $encryptedElementsElements */
- $encryptedElementsElements = XMLXPath::xpQuery(
- $encryptedElementsElement,
- './sp:XPath/following-sibling::*',
- $xpCache,
- );
-
- $this->assertCount(1, $encryptedElementsElements);
- $this->assertEquals('ssp:Chunk', $encryptedElementsElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a EncryptedElements from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -106,10 +95,22 @@ public function testMarshalling(): void
[$chunk],
[$attr],
);
+ $encryptedElementsElement = $encryptedElements->toXML();
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($encryptedElements),
+ // Test for an XPath
+ $xpCache = XMLXPath::getXPath($encryptedElementsElement);
+ $encryptedElementsElements = XMLXPath::xpQuery($encryptedElementsElement, './sp:XPath', $xpCache);
+ $this->assertCount(1, $encryptedElementsElements);
+
+ // Test ordering of EncryptedElements contents
+ /** @var \DOMElement[] $encryptedElementsElements */
+ $encryptedElementsElements = XMLXPath::xpQuery(
+ $encryptedElementsElement,
+ './sp:XPath/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $encryptedElementsElements);
+ $this->assertEquals('ssp:Chunk', $encryptedElementsElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/EncryptedPartsTest.php b/tests/SecurityPolicy/XML/sp_200507/EncryptedPartsTest.php
index e663504..d7df9e8 100644
--- a/tests/SecurityPolicy/XML/sp_200507/EncryptedPartsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/EncryptedPartsTest.php
@@ -71,12 +71,13 @@ public function testMarshalling(): void
'some',
)->documentElement);
- $EncryptedParts = new EncryptedParts($body, [$header], [$chunk], [$attr]);
+ $encryptedParts = new EncryptedParts($body, [$header], [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($EncryptedParts),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($encryptedParts);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/HeaderTest.php b/tests/SecurityPolicy/XML/sp_200507/HeaderTest.php
index 4f274c3..752dd0a 100644
--- a/tests/SecurityPolicy/XML/sp_200507/HeaderTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/HeaderTest.php
@@ -61,9 +61,10 @@ public function testMarshalling(): void
[$attr],
);
- $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/SecurityPolicy/XML/sp_200507/HttpsTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/HttpsTokenTest.php
index 058c385..b45cc78 100644
--- a/tests/SecurityPolicy/XML/sp_200507/HttpsTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/HttpsTokenTest.php
@@ -62,9 +62,11 @@ public function testMarshalling(): void
)->documentElement);
$httpsToken = new HttpsToken(BooleanValue::fromBoolean(true), [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($httpsToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($httpsToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/IssuedTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/IssuedTokenTest.php
index 7cea77b..a97c6dc 100644
--- a/tests/SecurityPolicy/XML/sp_200507/IssuedTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/IssuedTokenTest.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\Test\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -48,11 +48,11 @@ final class IssuedTokenTest extends TestCase
use SerializableElementTestTrait;
- /** @var \DOMElement $referencePropertiesContent */
- protected static DOMElement $referencePropertiesContent;
+ /** @var \Dom\Element $referencePropertiesContent */
+ protected static Dom\Element $referencePropertiesContent;
- /** @var \DOMElement $referenceParametersContent */
- protected static DOMElement $referenceParametersContent;
+ /** @var \Dom\Element $referenceParametersContent */
+ protected static Dom\Element $referenceParametersContent;
/**
@@ -75,9 +75,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a IssuedToken from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -121,30 +125,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$includeToken, $attr1],
);
- $issuedTokenElement = $issuedToken->toXML();
-
- // Test for a Issuer
- $xpCache = XPath::getXPath($issuedTokenElement);
- $issuedTokenElements = XPath::xpQuery($issuedTokenElement, './sp:Issuer', $xpCache);
- $this->assertCount(1, $issuedTokenElements);
- // Test ordering of IssuedToken contents
- /** @var \DOMElement[] $issuedTokenElements */
- $issuedTokenElements = XPath::xpQuery($issuedTokenElement, './sp:Issuer/following-sibling::*', $xpCache);
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($issuedToken);
- $this->assertCount(2, $issuedTokenElements);
- $this->assertEquals('sp:RequestSecurityTokenTemplate', $issuedTokenElements[0]->tagName);
- $this->assertEquals('ssp:Chunk', $issuedTokenElements[1]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a IssuedToken from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -188,10 +180,19 @@ public function testMarshalling(): void
[$chunk],
[$includeToken, $attr1],
);
+ $issuedTokenElement = $issuedToken->toXML();
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuedToken),
- );
+ // Test for a Issuer
+ $xpCache = XPath::getXPath($issuedTokenElement);
+ $issuedTokenElements = XPath::xpQuery($issuedTokenElement, './sp:Issuer', $xpCache);
+ $this->assertCount(1, $issuedTokenElements);
+
+ // Test ordering of IssuedToken contents
+ /** @var \Dom\Element[] $issuedTokenElements */
+ $issuedTokenElements = XPath::xpQuery($issuedTokenElement, './sp:Issuer/following-sibling::*', $xpCache);
+
+ $this->assertCount(2, $issuedTokenElements);
+ $this->assertEquals('sp:RequestSecurityTokenTemplate', $issuedTokenElements[0]->tagName);
+ $this->assertEquals('ssp:Chunk', $issuedTokenElements[1]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/IssuerTest.php b/tests/SecurityPolicy/XML/sp_200507/IssuerTest.php
index 7f61d7c..dd2ac63 100644
--- a/tests/SecurityPolicy/XML/sp_200507/IssuerTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/IssuerTest.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\Test\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -38,14 +38,14 @@ final class IssuerTest extends TestCase
use SerializableElementTestTrait;
- /** @var \DOMElement $referencePropertiesContent */
- protected static DOMElement $referencePropertiesContent;
+ /** @var \Dom\Element $referencePropertiesContent */
+ protected static Dom\Element $referencePropertiesContent;
- /** @var \DOMElement $referenceParametersContent */
- protected static DOMElement $referenceParametersContent;
+ /** @var \Dom\Element $referenceParametersContent */
+ protected static Dom\Element $referenceParametersContent;
- /** @var \DOMElement $customContent */
- protected static DOMElement $customContent;
+ /** @var \Dom\Element $customContent */
+ protected static Dom\Element $customContent;
/**
@@ -106,9 +106,10 @@ public function testMarshalling(): void
[$attr1],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuer),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($issuer);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/KerberosTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/KerberosTokenTest.php
index 7924c97..be47635 100644
--- a/tests/SecurityPolicy/XML/sp_200507/KerberosTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/KerberosTokenTest.php
@@ -78,10 +78,12 @@ public function testMarshalling(): void
'some',
)->documentElement);
- $KerberosToken = new KerberosToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($KerberosToken),
- );
+ $kerberosToken = new KerberosToken([$chunk], [$includeToken->toAttribute(), $attr]);
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($kerberosToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/QNameAssertionTypeTestTrait.php b/tests/SecurityPolicy/XML/sp_200507/QNameAssertionTypeTestTrait.php
index 16bd682..8fcc90a 100644
--- a/tests/SecurityPolicy/XML/sp_200507/QNameAssertionTypeTestTrait.php
+++ b/tests/SecurityPolicy/XML/sp_200507/QNameAssertionTypeTestTrait.php
@@ -30,10 +30,11 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\AbstractQNameAssertionType $qna */
$qna = new static::$testedClass([$attr]);
- $this->assertEquals(
- static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
- strval($qna),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($qna);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -44,7 +45,7 @@ public function testMarshallingWithoutNSAttr(): void
{
$xmlRepresentation = clone static::$xmlRepresentation;
$xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'attr1');
- $xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'ssp');
+ $xmlRepresentation->documentElement->removeAttributeNS(C::NS_XMLNS, 'ssp');
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\AbstractQNameAssertionType $qna */
$qna = new static::$testedClass();
@@ -66,7 +67,7 @@ public function testUnmarshallingWithoutNSAttr(): void
{
$xmlRepresentation = clone static::$xmlRepresentation;
$xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'attr1');
- $xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'ssp');
+ $xmlRepresentation->documentElement->removeAttributeNS(C::NS_XMLNS, 'ssp');
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200507\AbstractQNameAssertionType $qna */
$qna = static::$testedClass::fromXML($xmlRepresentation->documentElement);
diff --git a/tests/SecurityPolicy/XML/sp_200507/RelTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/RelTokenTest.php
index 1bfeb05..2631528 100644
--- a/tests/SecurityPolicy/XML/sp_200507/RelTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/RelTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$relToken = new RelToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($relToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($relToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/RequestSecurityTokenTemplateTest.php b/tests/SecurityPolicy/XML/sp_200507/RequestSecurityTokenTemplateTest.php
index 249c652..016adc4 100644
--- a/tests/SecurityPolicy/XML/sp_200507/RequestSecurityTokenTemplateTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/RequestSecurityTokenTemplateTest.php
@@ -65,10 +65,11 @@ public function testMarshalling(): void
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requestSecurityTokenTemplateElements),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($requestSecurityTokenTemplateElements);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/RequiredElementsTest.php b/tests/SecurityPolicy/XML/sp_200507/RequiredElementsTest.php
index a892312..12c8996 100644
--- a/tests/SecurityPolicy/XML/sp_200507/RequiredElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/RequiredElementsTest.php
@@ -107,9 +107,10 @@ public function testMarshalling(): void
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requiredElements),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($requiredElements);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SamlTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/SamlTokenTest.php
index 37f31f9..adb952c 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SamlTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SamlTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$samlToken = new SamlToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($samlToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($samlToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SecureConversationTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/SecureConversationTokenTest.php
index 16fc521..cbb7b3a 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SecureConversationTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SecureConversationTokenTest.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\Test\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -47,11 +47,11 @@ final class SecureConversationTokenTest extends TestCase
use SerializableElementTestTrait;
- /** @var \DOMElement $referencePropertiesContent */
- protected static DOMElement $referencePropertiesContent;
+ /** @var \Dom\Element $referencePropertiesContent */
+ protected static Dom\Element $referencePropertiesContent;
- /** @var \DOMElement $referenceParametersContent */
- protected static DOMElement $referenceParametersContent;
+ /** @var \Dom\Element $referenceParametersContent */
+ protected static Dom\Element $referenceParametersContent;
/**
@@ -74,9 +74,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a SecureConversationToken from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -113,33 +117,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$includeToken, $attr1],
);
- $secureConversationTokenElement = $secureConversationToken->toXML();
-
- // Test for a Issuer
- $xpCache = XPath::getXPath($secureConversationTokenElement);
- $secureConversationTokenElements = XPath::xpQuery($secureConversationTokenElement, './sp:Issuer', $xpCache);
- $this->assertCount(1, $secureConversationTokenElements);
- // Test ordering of SecureConversationToken contents
- /** @var \DOMElement[] $secureConversationTokenElements */
- $secureConversationTokenElements = XPath::xpQuery(
- $secureConversationTokenElement,
- './sp:Issuer/following-sibling::*',
- $xpCache,
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($secureConversationToken);
- $this->assertCount(1, $secureConversationTokenElements);
- $this->assertEquals('ssp:Chunk', $secureConversationTokenElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a SecureConversationToken from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -176,10 +165,22 @@ public function testMarshalling(): void
[$chunk],
[$includeToken, $attr1],
);
+ $secureConversationTokenElement = $secureConversationToken->toXML();
+
+ // Test for a Issuer
+ $xpCache = XPath::getXPath($secureConversationTokenElement);
+ $secureConversationTokenElements = XPath::xpQuery($secureConversationTokenElement, './sp:Issuer', $xpCache);
+ $this->assertCount(1, $secureConversationTokenElements);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($secureConversationToken),
+ // Test ordering of SecureConversationToken contents
+ /** @var \Dom\Element[] $secureConversationTokenElements */
+ $secureConversationTokenElements = XPath::xpQuery(
+ $secureConversationTokenElement,
+ './sp:Issuer/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $secureConversationTokenElements);
+ $this->assertEquals('ssp:Chunk', $secureConversationTokenElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SecurityContextTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/SecurityContextTokenTest.php
index 7aec801..323c73b 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SecurityContextTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SecurityContextTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$securityContextToken = new SecurityContextToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($securityContextToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($securityContextToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SignedElementsTest.php b/tests/SecurityPolicy/XML/sp_200507/SignedElementsTest.php
index 09cb0b9..4169f62 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SignedElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SignedElementsTest.php
@@ -50,9 +50,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a SignedElements from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -60,39 +64,24 @@ public function testMarshallingElementOrdering(): void
'some',
)->documentElement);
- $SignedElements = new SignedElements(
+ $signedElements = new SignedElements(
[$xpath],
AnyURIValue::fromString('urn:x-simplesamlphp:version'),
[$chunk],
[$attr],
);
- $SignedElementsElement = $SignedElements->toXML();
- // Test for an XPath
- $xpCache = XMLXPath::getXPath($SignedElementsElement);
- $SignedElementsElements = XMLXPath::xpQuery($SignedElementsElement, './sp:XPath', $xpCache);
- $this->assertCount(1, $SignedElementsElements);
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($signedElements);
- // Test ordering of SignedElements contents
- /** @var \DOMElement[] $signedElementsElements */
- $signedElementsElements = XMLXPath::xpQuery(
- $SignedElementsElement,
- './sp:XPath/following-sibling::*',
- $xpCache,
- );
-
- $this->assertCount(1, $signedElementsElements);
- $this->assertEquals('ssp:Chunk', $signedElementsElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a SignedElements from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -100,16 +89,28 @@ public function testMarshalling(): void
'some',
)->documentElement);
- $signedElements = new SignedElements(
+ $SignedElements = new SignedElements(
[$xpath],
AnyURIValue::fromString('urn:x-simplesamlphp:version'),
[$chunk],
[$attr],
);
+ $SignedElementsElement = $SignedElements->toXML();
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($signedElements),
+ // Test for an XPath
+ $xpCache = XMLXPath::getXPath($SignedElementsElement);
+ $SignedElementsElements = XMLXPath::xpQuery($SignedElementsElement, './sp:XPath', $xpCache);
+ $this->assertCount(1, $SignedElementsElements);
+
+ // Test ordering of SignedElements contents
+ /** @var \DOMElement[] $signedElementsElements */
+ $signedElementsElements = XMLXPath::xpQuery(
+ $SignedElementsElement,
+ './sp:XPath/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $signedElementsElements);
+ $this->assertEquals('ssp:Chunk', $signedElementsElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SignedPartsTest.php b/tests/SecurityPolicy/XML/sp_200507/SignedPartsTest.php
index 5ee9f29..fda8a7e 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SignedPartsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SignedPartsTest.php
@@ -87,10 +87,11 @@ public function testMarshalling(): void
)->documentElement);
$signedParts = new SignedParts($body, [$header], [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($signedParts),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($signedParts);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/SpnegoContextTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/SpnegoContextTokenTest.php
index 6e19ffb..07340d0 100644
--- a/tests/SecurityPolicy/XML/sp_200507/SpnegoContextTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/SpnegoContextTokenTest.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\Test\WebServices\SecurityPolicy\XML\sp_200507;
-use DOMElement;
+use Dom;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -47,11 +47,11 @@ final class SpnegoContextTokenTest extends TestCase
use SerializableElementTestTrait;
- /** @var \DOMElement $referencePropertiesContent */
- protected static DOMElement $referencePropertiesContent;
+ /** @var \Dom\Element $referencePropertiesContent */
+ protected static Dom\Element $referencePropertiesContent;
- /** @var \DOMElement $referenceParametersContent */
- protected static DOMElement $referenceParametersContent;
+ /** @var \Dom\Element $referenceParametersContent */
+ protected static Dom\Element $referenceParametersContent;
/**
@@ -74,9 +74,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a SpnegoContextToken from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -113,33 +117,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$includeToken, $attr1],
);
- $spnegoContextTokenElement = $spnegoContextToken->toXML();
-
- // Test for a Issuer
- $xpCache = XPath::getXPath($spnegoContextTokenElement);
- $spnegoContextTokenElements = XPath::xpQuery($spnegoContextTokenElement, './sp:Issuer', $xpCache);
- $this->assertCount(1, $spnegoContextTokenElements);
- // Test ordering of SpnegoContextToken contents
- /** @var \DOMElement[] $spnegoContextTokenElements */
- $spnegoContextTokenElements = XPath::xpQuery(
- $spnegoContextTokenElement,
- './sp:Issuer/following-sibling::*',
- $xpCache,
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($spnegoContextToken);
- $this->assertCount(1, $spnegoContextTokenElements);
- $this->assertEquals('ssp:Chunk', $spnegoContextTokenElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a SpnegoContextToken from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$attr1 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
$attr2 = new XMLAttribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
@@ -176,10 +165,22 @@ public function testMarshalling(): void
[$chunk],
[$includeToken, $attr1],
);
+ $spnegoContextTokenElement = $spnegoContextToken->toXML();
+
+ // Test for a Issuer
+ $xpCache = XPath::getXPath($spnegoContextTokenElement);
+ $spnegoContextTokenElements = XPath::xpQuery($spnegoContextTokenElement, './sp:Issuer', $xpCache);
+ $this->assertCount(1, $spnegoContextTokenElements);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($spnegoContextToken),
+ // Test ordering of SpnegoContextToken contents
+ /** @var \Dom\Element[] $spnegoContextTokenElements */
+ $spnegoContextTokenElements = XPath::xpQuery(
+ $spnegoContextTokenElement,
+ './sp:Issuer/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $spnegoContextTokenElements);
+ $this->assertEquals('ssp:Chunk', $spnegoContextTokenElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/UsernameTokenTest.php b/tests/SecurityPolicy/XML/sp_200507/UsernameTokenTest.php
index 001b183..10f2a48 100644
--- a/tests/SecurityPolicy/XML/sp_200507/UsernameTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/UsernameTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$usernameToken = new UsernameToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($usernameToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($usernameToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/X509TokenTest.php b/tests/SecurityPolicy/XML/sp_200507/X509TokenTest.php
index d72f8a0..25c00c1 100644
--- a/tests/SecurityPolicy/XML/sp_200507/X509TokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/X509TokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$x509Token = new X509Token([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($x509Token),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($x509Token);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200507/XPathTest.php b/tests/SecurityPolicy/XML/sp_200507/XPathTest.php
index c78c1ce..09553ab 100644
--- a/tests/SecurityPolicy/XML/sp_200507/XPathTest.php
+++ b/tests/SecurityPolicy/XML/sp_200507/XPathTest.php
@@ -50,9 +50,10 @@ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($xpath),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($xpath);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/AttachmentsTest.php b/tests/SecurityPolicy/XML/sp_200702/AttachmentsTest.php
index 093ed94..93d94e5 100644
--- a/tests/SecurityPolicy/XML/sp_200702/AttachmentsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/AttachmentsTest.php
@@ -51,9 +51,10 @@ public function testMarshalling(): void
{
$attachments = new Attachments();
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($attachments),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($attachments);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/BodyTest.php b/tests/SecurityPolicy/XML/sp_200702/BodyTest.php
index 06424bb..d35da64 100644
--- a/tests/SecurityPolicy/XML/sp_200702/BodyTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/BodyTest.php
@@ -51,9 +51,10 @@ public function testMarshalling(): void
{
$body = new Body();
- $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/SecurityPolicy/XML/sp_200702/ContentEncryptedElementsTest.php b/tests/SecurityPolicy/XML/sp_200702/ContentEncryptedElementsTest.php
index 30d15cb..49b4c97 100644
--- a/tests/SecurityPolicy/XML/sp_200702/ContentEncryptedElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/ContentEncryptedElementsTest.php
@@ -50,6 +50,35 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
+ /**
+ * Test that creating a ContentEncryptedElements from scratch works.
+ */
+ public function testMarshalling(): void
+ {
+ $xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
+ $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
+ $chunk = new Chunk(DOMDocumentFactory::fromString(
+ 'some',
+ )->documentElement);
+
+ $contentEncryptedElements = new ContentEncryptedElements(
+ [$xpath],
+ AnyURIValue::fromString('urn:x-simplesamlphp:version'),
+ [$chunk],
+ [$attr],
+ );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($contentEncryptedElements);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
+ }
+
+
/**
*/
public function testMarshallingElementOrdering(): void
@@ -88,31 +117,4 @@ public function testMarshallingElementOrdering(): void
$this->assertCount(1, $contentEncryptedElementsElements);
$this->assertEquals('ssp:Chunk', $contentEncryptedElementsElements[0]->tagName);
}
-
-
- // test marshalling
-
-
- /**
- * Test that creating a ContentEncryptedElements from scratch works.
- */
- public function testMarshalling(): void
- {
- $xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
- $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
- $chunk = new Chunk(DOMDocumentFactory::fromString(
- 'some',
- )->documentElement);
-
- $contentEncryptedElements = new ContentEncryptedElements(
- [$xpath],
- AnyURIValue::fromString('urn:x-simplesamlphp:version'),
- [$chunk],
- [$attr],
- );
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($contentEncryptedElements),
- );
- }
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/EncryptedElementsTest.php b/tests/SecurityPolicy/XML/sp_200702/EncryptedElementsTest.php
index b4a4292..29447b9 100644
--- a/tests/SecurityPolicy/XML/sp_200702/EncryptedElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/EncryptedElementsTest.php
@@ -50,9 +50,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a EncryptedElements from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -66,33 +70,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$attr],
);
- $encryptedElementsElement = $encryptedElements->toXML();
-
- // Test for an XPath
- $xpCache = XMLXPath::getXPath($encryptedElementsElement);
- $encryptedElementsElements = XMLXPath::xpQuery($encryptedElementsElement, './sp:XPath', $xpCache);
- $this->assertCount(1, $encryptedElementsElements);
- // Test ordering of EncryptedElements contents
- /** @var \DOMElement[] $encryptedElementsElements */
- $encryptedElementsElements = XMLXPath::xpQuery(
- $encryptedElementsElement,
- './sp:XPath/following-sibling::*',
- $xpCache,
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($encryptedElements);
- $this->assertCount(1, $encryptedElementsElements);
- $this->assertEquals('ssp:Chunk', $encryptedElementsElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a EncryptedElements from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -106,9 +95,22 @@ public function testMarshalling(): void
[$chunk],
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($encryptedElements),
+ $encryptedElementsElement = $encryptedElements->toXML();
+
+ // Test for an XPath
+ $xpCache = XMLXPath::getXPath($encryptedElementsElement);
+ $encryptedElementsElements = XMLXPath::xpQuery($encryptedElementsElement, './sp:XPath', $xpCache);
+ $this->assertCount(1, $encryptedElementsElements);
+
+ // Test ordering of EncryptedElements contents
+ /** @var \DOMElement[] $encryptedElementsElements */
+ $encryptedElementsElements = XMLXPath::xpQuery(
+ $encryptedElementsElement,
+ './sp:XPath/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $encryptedElementsElements);
+ $this->assertEquals('ssp:Chunk', $encryptedElementsElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/EncryptedPartsTest.php b/tests/SecurityPolicy/XML/sp_200702/EncryptedPartsTest.php
index 7576335..c78970e 100644
--- a/tests/SecurityPolicy/XML/sp_200702/EncryptedPartsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/EncryptedPartsTest.php
@@ -73,12 +73,13 @@ public function testMarshalling(): void
'some',
)->documentElement);
- $EncryptedParts = new EncryptedParts($body, [$header], $attachments, [$chunk], [$attr]);
+ $encryptedParts = new EncryptedParts($body, [$header], $attachments, [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($EncryptedParts),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($encryptedParts);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/HeaderTest.php b/tests/SecurityPolicy/XML/sp_200702/HeaderTest.php
index f59aab8..35b6dcf 100644
--- a/tests/SecurityPolicy/XML/sp_200702/HeaderTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/HeaderTest.php
@@ -61,9 +61,10 @@ public function testMarshalling(): void
[$attr],
);
- $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/SecurityPolicy/XML/sp_200702/HttpsTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/HttpsTokenTest.php
index 33795e9..60a5abd 100644
--- a/tests/SecurityPolicy/XML/sp_200702/HttpsTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/HttpsTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$httpsToken = new HttpsToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($httpsToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($httpsToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/IssuedTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/IssuedTokenTest.php
index 288ae84..ea62329 100644
--- a/tests/SecurityPolicy/XML/sp_200702/IssuedTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/IssuedTokenTest.php
@@ -119,9 +119,11 @@ public function testMarshalling(): void
[$chunk],
[$includeToken->toAttribute(), $attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuedToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($issuedToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/IssuerNameTest.php b/tests/SecurityPolicy/XML/sp_200702/IssuerNameTest.php
index 8b87bb0..02e29a9 100644
--- a/tests/SecurityPolicy/XML/sp_200702/IssuerNameTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/IssuerNameTest.php
@@ -50,9 +50,10 @@ public function testMarshalling(): void
{
$issuerName = IssuerName::fromString('urn:x-simplesamlphp:namespace');
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuerName),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($issuerName);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/IssuerTest.php b/tests/SecurityPolicy/XML/sp_200702/IssuerTest.php
index d637533..02ce50f 100644
--- a/tests/SecurityPolicy/XML/sp_200702/IssuerTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/IssuerTest.php
@@ -4,7 +4,7 @@
namespace SimpleSAML\Test\WebServices\SecurityPolicy\XML\sp_200702;
-use DOMElement;
+use Dom;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
@@ -34,14 +34,14 @@ final class IssuerTest extends TestCase
use SerializableElementTestTrait;
- /** @var \DOMElement $referenceParametersContent */
- protected static DOMElement $referenceParametersContent;
+ /** @var \Dom\Element $referenceParametersContent */
+ protected static Dom\Element $referenceParametersContent;
- /** @var \DOMElement $metadataContent */
- protected static DOMElement $metadataContent;
+ /** @var \Dom\Element $metadataContent */
+ protected static Dom\Element $metadataContent;
- /** @var \DOMElement $customContent */
- protected static DOMElement $customContent;
+ /** @var \Dom\Element $customContent */
+ protected static Dom\Element $customContent;
/**
@@ -93,9 +93,10 @@ public function testMarshalling(): void
[$attr1],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($issuer),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($issuer);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/KerberosTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/KerberosTokenTest.php
index 9846c9e..6dbe7a8 100644
--- a/tests/SecurityPolicy/XML/sp_200702/KerberosTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/KerberosTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$kerberosToken = new KerberosToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($kerberosToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($kerberosToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/KeyValueTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/KeyValueTokenTest.php
index 02b290d..f927895 100644
--- a/tests/SecurityPolicy/XML/sp_200702/KeyValueTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/KeyValueTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
)->documentElement);
$keyValueToken = new KeyValueToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($keyValueToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($keyValueToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/QNameAssertionTypeTestTrait.php b/tests/SecurityPolicy/XML/sp_200702/QNameAssertionTypeTestTrait.php
index dee5161..7fd8756 100644
--- a/tests/SecurityPolicy/XML/sp_200702/QNameAssertionTypeTestTrait.php
+++ b/tests/SecurityPolicy/XML/sp_200702/QNameAssertionTypeTestTrait.php
@@ -30,10 +30,11 @@ public function testMarshalling(): void
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractQNameAssertionType $qna */
$qna = new static::$testedClass([$attr]);
- $this->assertEquals(
- static::$xmlRepresentation->saveXML(static::$xmlRepresentation->documentElement),
- strval($qna),
- );
+ $expectedXml = static::$xmlRepresentation->saveXml(static::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($qna);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
@@ -44,7 +45,7 @@ public function testMarshallingWithoutNSAttr(): void
{
$xmlRepresentation = clone static::$xmlRepresentation;
$xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'attr1');
- $xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'ssp');
+ $xmlRepresentation->documentElement->removeAttributeNS(C::NS_XMLNS, 'ssp');
/** @var \SimpleSAML\WebServices\SecurityPolicy\XML\sp_200702\AbstractQNameAssertionType $qna */
$qna = new static::$testedClass();
@@ -66,7 +67,7 @@ public function testUnmarshallingWithoutNSAttr(): void
{
$xmlRepresentation = clone static::$xmlRepresentation;
$xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'attr1');
- $xmlRepresentation->documentElement->removeAttributeNS(C::NAMESPACE, 'ssp');
+ $xmlRepresentation->documentElement->removeAttributeNS(C::NS_XMLNS, 'ssp');
$qna = static::$testedClass::fromXML($xmlRepresentation->documentElement);
diff --git a/tests/SecurityPolicy/XML/sp_200702/RelTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/RelTokenTest.php
index a90af27..b473343 100644
--- a/tests/SecurityPolicy/XML/sp_200702/RelTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/RelTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$relToken = new RelToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($relToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($relToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/RequestSecurityTokenTemplateTest.php b/tests/SecurityPolicy/XML/sp_200702/RequestSecurityTokenTemplateTest.php
index 393da69..b7c09b4 100644
--- a/tests/SecurityPolicy/XML/sp_200702/RequestSecurityTokenTemplateTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/RequestSecurityTokenTemplateTest.php
@@ -65,10 +65,11 @@ public function testMarshalling(): void
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requestSecurityTokenTemplateElements),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($requestSecurityTokenTemplateElements);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/RequiredElementsTest.php b/tests/SecurityPolicy/XML/sp_200702/RequiredElementsTest.php
index f755d5c..c0efaf5 100644
--- a/tests/SecurityPolicy/XML/sp_200702/RequiredElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/RequiredElementsTest.php
@@ -50,9 +50,13 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a RequiredElements from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -66,33 +70,18 @@ public function testMarshallingElementOrdering(): void
[$chunk],
[$attr],
);
- $requiredElementsElement = $requiredElements->toXML();
-
- // Test for an XPath
- $xpCache = XMLXPath::getXPath($requiredElementsElement);
- $requiredElementsElements = XMLXPath::xpQuery($requiredElementsElement, './sp:XPath', $xpCache);
- $this->assertCount(1, $requiredElementsElements);
- // Test ordering of RequiredElements contents
- /** @var \DOMElement[] $requiredElementsElements */
- $requiredElementsElements = XMLXPath::xpQuery(
- $requiredElementsElement,
- './sp:XPath/following-sibling::*',
- $xpCache,
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($requiredElements);
- $this->assertCount(1, $requiredElementsElements);
- $this->assertEquals('ssp:Chunk', $requiredElementsElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a RequiredElements from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
@@ -106,9 +95,22 @@ public function testMarshalling(): void
[$chunk],
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requiredElements),
+ $requiredElementsElement = $requiredElements->toXML();
+
+ // Test for an XPath
+ $xpCache = XMLXPath::getXPath($requiredElementsElement);
+ $requiredElementsElements = XMLXPath::xpQuery($requiredElementsElement, './sp:XPath', $xpCache);
+ $this->assertCount(1, $requiredElementsElements);
+
+ // Test ordering of RequiredElements contents
+ /** @var \DOMElement[] $requiredElementsElements */
+ $requiredElementsElements = XMLXPath::xpQuery(
+ $requiredElementsElement,
+ './sp:XPath/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $requiredElementsElements);
+ $this->assertEquals('ssp:Chunk', $requiredElementsElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/RequiredPartsTest.php b/tests/SecurityPolicy/XML/sp_200702/RequiredPartsTest.php
index 3b43748..203e2df 100644
--- a/tests/SecurityPolicy/XML/sp_200702/RequiredPartsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/RequiredPartsTest.php
@@ -51,6 +51,34 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
+ /**
+ * Test that creating a RequiredParts from scratch works.
+ */
+ public function testMarshalling(): void
+ {
+ $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
+ $header = new Header(
+ AnyURIValue::fromString('urn:x-simplesamlphp:namespace'),
+ QNameValue::fromString('{urn:x-simplesamlphp}name'),
+ [$attr],
+ );
+ $chunk = new Chunk(DOMDocumentFactory::fromString(
+ 'some',
+ )->documentElement);
+
+ $requiredParts = new RequiredParts([$header], [$chunk], [$attr]);
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($requiredParts);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
+ }
+
+
/**
* Adding an empty RequiredParts element should yield an empty element.
*/
@@ -95,30 +123,4 @@ public function testMarshallingElementOrdering(): void
$this->assertCount(1, $requiredPartsElements);
$this->assertEquals('ssp:Chunk', $requiredPartsElements[0]->tagName);
}
-
-
- // test marshalling
-
-
- /**
- * Test that creating a RequiredParts from scratch works.
- */
- public function testMarshalling(): void
- {
- $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
- $header = new Header(
- AnyURIValue::fromString('urn:x-simplesamlphp:namespace'),
- QNameValue::fromString('{urn:x-simplesamlphp}name'),
- [$attr],
- );
- $chunk = new Chunk(DOMDocumentFactory::fromString(
- 'some',
- )->documentElement);
-
- $requiredParts = new RequiredParts([$header], [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($requiredParts),
- );
- }
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SamlTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/SamlTokenTest.php
index 6f39264..017c1c5 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SamlTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SamlTokenTest.php
@@ -52,21 +52,6 @@ public static function setUpBeforeClass(): void
// test marshalling
- /**
- * Adding an empty SamlToken element should yield an empty element.
- */
- public function testMarshallingEmptyElement(): void
- {
- $spns = C::NS_SEC_POLICY_12;
- $samlToken = new SamlToken();
- $this->assertEquals(
- "",
- strval($samlToken),
- );
- $this->assertTrue($samlToken->isEmptyElement());
- }
-
-
/**
* Test that creating a SamlToken from scratch works.
*/
@@ -79,9 +64,26 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$samlToken = new SamlToken([$chunk], [$includeToken->toAttribute(), $attr]);
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($samlToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
+ }
+
+
+ /**
+ * Adding an empty SamlToken element should yield an empty element.
+ */
+ public function testMarshallingEmptyElement(): void
+ {
+ $spns = C::NS_SEC_POLICY_12;
+ $samlToken = new SamlToken();
$this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
+ "",
strval($samlToken),
);
+ $this->assertTrue($samlToken->isEmptyElement());
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SecureConversationTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/SecureConversationTokenTest.php
index 97991c5..346ad61 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SecureConversationTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SecureConversationTokenTest.php
@@ -51,67 +51,68 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
/**
+ * Test that creating a SecureConversationToken from scratch works.
*/
- public function testMarshallingElementOrdering(): void
+ public function testMarshalling(): void
{
- $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$chunk = new Chunk(DOMDocumentFactory::fromString(
'some',
)->documentElement);
+ $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
+
$secureConversationToken = new SecureConversationToken(
$issuer,
[$chunk],
[$includeToken->toAttribute(), $attr],
);
- $secureConversationTokenElement = $secureConversationToken->toXML();
-
- // Test for a IssuerName
- $xpCache = XPath::getXPath($secureConversationTokenElement);
- $secureConversationTokenElements = XPath::xpQuery($secureConversationTokenElement, './sp:IssuerName', $xpCache);
- $this->assertCount(1, $secureConversationTokenElements);
- // Test ordering of SecureConversationToken contents
- /** @var \DOMElement[] $secureConversationTokenElements */
- $secureConversationTokenElements = XPath::xpQuery(
- $secureConversationTokenElement,
- './sp:IssuerName/following-sibling::*',
- $xpCache,
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($secureConversationToken);
- $this->assertCount(1, $secureConversationTokenElements);
- $this->assertEquals('ssp:Chunk', $secureConversationTokenElements[0]->tagName);
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
- // test marshalling
-
-
/**
- * Test that creating a SecureConversationToken from scratch works.
*/
- public function testMarshalling(): void
+ public function testMarshallingElementOrdering(): void
{
+ $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
$attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$chunk = new Chunk(DOMDocumentFactory::fromString(
'some',
)->documentElement);
- $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
-
$secureConversationToken = new SecureConversationToken(
$issuer,
[$chunk],
[$includeToken->toAttribute(), $attr],
);
+ $secureConversationTokenElement = $secureConversationToken->toXML();
+
+ // Test for a IssuerName
+ $xpCache = XPath::getXPath($secureConversationTokenElement);
+ $secureConversationTokenElements = XPath::xpQuery($secureConversationTokenElement, './sp:IssuerName', $xpCache);
+ $this->assertCount(1, $secureConversationTokenElements);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($secureConversationToken),
+ // Test ordering of SecureConversationToken contents
+ /** @var \DOMElement[] $secureConversationTokenElements */
+ $secureConversationTokenElements = XPath::xpQuery(
+ $secureConversationTokenElement,
+ './sp:IssuerName/following-sibling::*',
+ $xpCache,
);
+
+ $this->assertCount(1, $secureConversationTokenElements);
+ $this->assertEquals('ssp:Chunk', $secureConversationTokenElements[0]->tagName);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SecurityContextTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/SecurityContextTokenTest.php
index f72a2fa..3a126c5 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SecurityContextTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SecurityContextTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$securityContextToken = new SecurityContextToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($securityContextToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($securityContextToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SignedElementsTest.php b/tests/SecurityPolicy/XML/sp_200702/SignedElementsTest.php
index dd2296f..ad48fc7 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SignedElementsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SignedElementsTest.php
@@ -106,9 +106,11 @@ public function testMarshalling(): void
[$chunk],
[$attr],
);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($signedElements),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($signedElements);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SignedPartsTest.php b/tests/SecurityPolicy/XML/sp_200702/SignedPartsTest.php
index 06d9f6d..1efd51e 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SignedPartsTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SignedPartsTest.php
@@ -89,10 +89,12 @@ public function testMarshalling(): void
)->documentElement);
$signedParts = new SignedParts($body, [$header], $attachments, [$chunk], [$attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($signedParts),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($signedParts);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/SpnegoContextTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/SpnegoContextTokenTest.php
index ca7529e..a3250ab 100644
--- a/tests/SecurityPolicy/XML/sp_200702/SpnegoContextTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/SpnegoContextTokenTest.php
@@ -51,6 +51,32 @@ public static function setUpBeforeClass(): void
}
+ // test marshalling
+
+
+ /**
+ * Test that creating a SpnegoContextToken from scratch works.
+ */
+ public function testMarshalling(): void
+ {
+ $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
+ $includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
+ $chunk = new Chunk(DOMDocumentFactory::fromString(
+ 'some',
+ )->documentElement);
+
+ $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
+
+ $spnegoContextToken = new SpnegoContextToken($issuer, [$chunk], [$includeToken->toAttribute(), $attr]);
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($spnegoContextToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
+ }
+
+
/**
*/
public function testMarshallingElementOrdering(): void
@@ -81,28 +107,4 @@ public function testMarshallingElementOrdering(): void
$this->assertCount(1, $spnegoContextTokenElements);
$this->assertEquals('ssp:Chunk', $spnegoContextTokenElements[0]->tagName);
}
-
-
- // test marshalling
-
-
- /**
- * Test that creating a SpnegoContextToken from scratch works.
- */
- public function testMarshalling(): void
- {
- $attr = new XMLAttribute(C::NAMESPACE, 'ssp', 'attr1', StringValue::fromString('value1'));
- $includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
- $chunk = new Chunk(DOMDocumentFactory::fromString(
- 'some',
- )->documentElement);
-
- $issuer = IssuerName::fromString('urn:x-simplesamlphp:issuer');
-
- $spnegoContextToken = new SpnegoContextToken($issuer, [$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($spnegoContextToken),
- );
- }
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/UsernameTokenTest.php b/tests/SecurityPolicy/XML/sp_200702/UsernameTokenTest.php
index 87a8db0..c7dcdc9 100644
--- a/tests/SecurityPolicy/XML/sp_200702/UsernameTokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/UsernameTokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$usernameToken = new UsernameToken([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($usernameToken),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($usernameToken);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/X509TokenTest.php b/tests/SecurityPolicy/XML/sp_200702/X509TokenTest.php
index 645876f..51bd9be 100644
--- a/tests/SecurityPolicy/XML/sp_200702/X509TokenTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/X509TokenTest.php
@@ -79,9 +79,11 @@ public function testMarshalling(): void
$includeToken = IncludeTokenValue::fromEnum(IncludeToken::Always);
$x509Token = new X509Token([$chunk], [$includeToken->toAttribute(), $attr]);
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($x509Token),
- );
+
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($x509Token);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/SecurityPolicy/XML/sp_200702/XPathTest.php b/tests/SecurityPolicy/XML/sp_200702/XPathTest.php
index c5d594c..66afb84 100644
--- a/tests/SecurityPolicy/XML/sp_200702/XPathTest.php
+++ b/tests/SecurityPolicy/XML/sp_200702/XPathTest.php
@@ -50,9 +50,10 @@ public function testMarshalling(): void
{
$xpath = XPath::fromString('/bookstore/book[price>35.00]/title');
- $this->assertEquals(
- self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
- strval($xpath),
- );
+ $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement);
+ $this->assertNotFalse($expectedXml);
+ $actualXml = strval($xpath);
+
+ $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml);
}
}
diff --git a/tests/resources/xml/sp/200507/AlgorithmSuite.xml b/tests/resources/xml/sp/200507/AlgorithmSuite.xml
index a5c5979..8b7187f 100644
--- a/tests/resources/xml/sp/200507/AlgorithmSuite.xml
+++ b/tests/resources/xml/sp/200507/AlgorithmSuite.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/AsymmetricBinding.xml b/tests/resources/xml/sp/200507/AsymmetricBinding.xml
index 7881961..a9fc9d7 100644
--- a/tests/resources/xml/sp/200507/AsymmetricBinding.xml
+++ b/tests/resources/xml/sp/200507/AsymmetricBinding.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/BootstrapPolicy.xml b/tests/resources/xml/sp/200507/BootstrapPolicy.xml
index e194705..ba9de25 100644
--- a/tests/resources/xml/sp/200507/BootstrapPolicy.xml
+++ b/tests/resources/xml/sp/200507/BootstrapPolicy.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/EncryptionToken.xml b/tests/resources/xml/sp/200507/EncryptionToken.xml
index 792f999..5d6dcab 100644
--- a/tests/resources/xml/sp/200507/EncryptionToken.xml
+++ b/tests/resources/xml/sp/200507/EncryptionToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/EndorsingSupportingTokens.xml b/tests/resources/xml/sp/200507/EndorsingSupportingTokens.xml
index 5f8c1b0..2a117f7 100644
--- a/tests/resources/xml/sp/200507/EndorsingSupportingTokens.xml
+++ b/tests/resources/xml/sp/200507/EndorsingSupportingTokens.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/InitiatorToken.xml b/tests/resources/xml/sp/200507/InitiatorToken.xml
index dc8e21a..16ba9e1 100644
--- a/tests/resources/xml/sp/200507/InitiatorToken.xml
+++ b/tests/resources/xml/sp/200507/InitiatorToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/Layout.xml b/tests/resources/xml/sp/200507/Layout.xml
index 5e84803..8510ecc 100644
--- a/tests/resources/xml/sp/200507/Layout.xml
+++ b/tests/resources/xml/sp/200507/Layout.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/ProtectionToken.xml b/tests/resources/xml/sp/200507/ProtectionToken.xml
index 5517fa0..3f7f6b2 100644
--- a/tests/resources/xml/sp/200507/ProtectionToken.xml
+++ b/tests/resources/xml/sp/200507/ProtectionToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/RecipientToken.xml b/tests/resources/xml/sp/200507/RecipientToken.xml
index 323199c..a09a196 100644
--- a/tests/resources/xml/sp/200507/RecipientToken.xml
+++ b/tests/resources/xml/sp/200507/RecipientToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/SignatureToken.xml b/tests/resources/xml/sp/200507/SignatureToken.xml
index 279f6e5..09585b3 100644
--- a/tests/resources/xml/sp/200507/SignatureToken.xml
+++ b/tests/resources/xml/sp/200507/SignatureToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/SignedEndorsingSupportingTokens.xml b/tests/resources/xml/sp/200507/SignedEndorsingSupportingTokens.xml
index 6e541f7..31ed661 100644
--- a/tests/resources/xml/sp/200507/SignedEndorsingSupportingTokens.xml
+++ b/tests/resources/xml/sp/200507/SignedEndorsingSupportingTokens.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/SignedSupportingTokens.xml b/tests/resources/xml/sp/200507/SignedSupportingTokens.xml
index 891fdd0..e56a225 100644
--- a/tests/resources/xml/sp/200507/SignedSupportingTokens.xml
+++ b/tests/resources/xml/sp/200507/SignedSupportingTokens.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/SupportingTokens.xml b/tests/resources/xml/sp/200507/SupportingTokens.xml
index ab338ae..11b59b1 100644
--- a/tests/resources/xml/sp/200507/SupportingTokens.xml
+++ b/tests/resources/xml/sp/200507/SupportingTokens.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/SymmetricBinding.xml b/tests/resources/xml/sp/200507/SymmetricBinding.xml
index 0bf6ef2..4810245 100644
--- a/tests/resources/xml/sp/200507/SymmetricBinding.xml
+++ b/tests/resources/xml/sp/200507/SymmetricBinding.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/TransportBinding.xml b/tests/resources/xml/sp/200507/TransportBinding.xml
index 61589e9..05bd8fc 100644
--- a/tests/resources/xml/sp/200507/TransportBinding.xml
+++ b/tests/resources/xml/sp/200507/TransportBinding.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/TransportToken.xml b/tests/resources/xml/sp/200507/TransportToken.xml
index 062acc0..0c43102 100644
--- a/tests/resources/xml/sp/200507/TransportToken.xml
+++ b/tests/resources/xml/sp/200507/TransportToken.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/Trust10.xml b/tests/resources/xml/sp/200507/Trust10.xml
index f809154..b7f76f8 100644
--- a/tests/resources/xml/sp/200507/Trust10.xml
+++ b/tests/resources/xml/sp/200507/Trust10.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/Wss10.xml b/tests/resources/xml/sp/200507/Wss10.xml
index b89a590..12a3f47 100644
--- a/tests/resources/xml/sp/200507/Wss10.xml
+++ b/tests/resources/xml/sp/200507/Wss10.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other
diff --git a/tests/resources/xml/sp/200507/Wss11.xml b/tests/resources/xml/sp/200507/Wss11.xml
index 8a2a66b..4bea6d8 100644
--- a/tests/resources/xml/sp/200507/Wss11.xml
+++ b/tests/resources/xml/sp/200507/Wss11.xml
@@ -1,5 +1,5 @@
-
-
+
+
Other