Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^8.5",
"ext-dom": "*",

"simplesamlphp/xml-cas": "~2.5",
"simplesamlphp/xml-cas": "dev-feature/dom-migration-php84",
"simplesamlphp/xml-common": "dev-feature/dom-migration-php84"
},
"require-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/XML/AbstractAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\Slate\XML;

use DOMElement;
use Dom;
use SimpleSAML\CAS\XML\AbstractCasElement;
use SimpleSAML\CAS\XML\AuthenticationDate;
use SimpleSAML\CAS\XML\IsFromNewLogin;
Expand Down Expand Up @@ -81,10 +81,10 @@ public function getIsFromNewLogin(): ?IsFromNewLogin
/**
* Convert this Attributes to XML.
*
* @param \DOMElement|null $parent The element we should append this Attributes to.
* @return \DOMElement
* @param \Dom\Element|null $parent The element we should append this Attributes to.
* @return \Dom\Element
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
6 changes: 3 additions & 3 deletions src/XML/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\Slate\XML;

use DOMElement;
use Dom;
use SimpleSAML\CAS\Assert\Assert;
use SimpleSAML\CAS\XML\AuthenticationDate;
use SimpleSAML\CAS\XML\IsFromNewLogin;
Expand All @@ -27,15 +27,15 @@ final class Attributes extends AbstractAttributes
/**
* Convert XML into a cas:attributes-element
*
* @param \DOMElement $xml The XML element we should load
* @param \Dom\Element $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
* if the supplied element is missing one of the mandatory attributes
*/
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::getNamespaceURI(), InvalidDOMElementException::class);
Expand Down
12 changes: 6 additions & 6 deletions src/XML/AuthenticationSuccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\Slate\XML;

use DOMElement;
use Dom;
use SimpleSAML\CAS\Assert\Assert;
use SimpleSAML\CAS\XML\Proxies;
use SimpleSAML\CAS\XML\ProxyGrantingTicket;
Expand Down Expand Up @@ -54,15 +54,15 @@ final public function __construct(
/**
* Convert XML into a cas:authenticationSuccess-element
*
* @param \DOMElement $xml The XML element we should load
* @param \Dom\Element $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
* if the supplied element is missing one of the mandatory attributes
*/
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::getNamespaceURI(), InvalidDOMElementException::class);
Expand Down Expand Up @@ -99,10 +99,10 @@ public static function fromXML(DOMElement $xml): static
/**
* Convert this AuthenticationSuccess to XML.
*
* @param \DOMElement|null $parent The element we should append this AuthenticationSuccess to.
* @return \DOMElement
* @param \Dom\Element|null $parent The element we should append this AuthenticationSuccess to.
* @return \Dom\Element
*/
public function toXML(?DOMElement $parent = null): DOMElement
public function toXML(?Dom\Element $parent = null): Dom\Element
{
$e = $this->instantiateParentElement($parent);

Expand Down
6 changes: 3 additions & 3 deletions src/XML/ServiceResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\Slate\XML;

use DOMElement;
use Dom;
use SimpleSAML\CAS\Assert\Assert;
use SimpleSAML\CAS\XML\AbstractServiceResponse;
use SimpleSAML\CAS\XML\AuthenticationFailure;
Expand Down Expand Up @@ -32,15 +32,15 @@ final class ServiceResponse extends AbstractServiceResponse implements SchemaVal
/**
* Convert XML into a cas:serviceResponse-element
*
* @param \DOMElement $xml The XML element we should load
* @param \Dom\Element $xml The XML element we should load
* @return static
*
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
* if the qualified name of the supplied element is wrong
* @throws \SimpleSAML\XMLSchema\Exception\MissingAttributeException
* if the supplied element is missing one of the mandatory attributes
*/
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::getNamespaceURI(), InvalidDOMElementException::class);
Expand Down
20 changes: 10 additions & 10 deletions tests/Slate/XML/AttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ public function testMarshalling(): void
$longTerm = LongTermAuthenticationRequestTokenUsed::fromString('true');
$isFromNewLogin = IsFromNewLogin::fromString('true');

/** @var \DOMElement $firstNameElt */
/** @var \Dom\Element $firstNameElt */
$firstNameElt = DOMDocumentFactory::fromString(
'<cas:firstname xmlns:cas="http://www.yale.edu/tp/cas">Example</cas:firstname>',
)->documentElement;

$firstName = new Chunk($firstNameElt);

/** @var \DOMElement $lastNameElt */
/** @var \Dom\Element $lastNameElt */
$lastNameElt = DOMDocumentFactory::fromString(
'<cas:lastname xmlns:cas="http://www.yale.edu/tp/cas">User</cas:lastname>',
)->documentElement;
$lastName = new Chunk($lastNameElt);

/** @var \DOMElement $emailElt */
/** @var \Dom\Element $emailElt */
$emailElt = DOMDocumentFactory::fromString(
'<cas:email xmlns:cas="http://www.yale.edu/tp/cas">example-user@technolutions.com</cas:email>',
)->documentElement;
Expand All @@ -82,11 +82,11 @@ public function testMarshalling(): void
'<cas:myAttribute xmlns:cas="http://www.yale.edu/tp/cas">myValue</cas:myAttribute>',
);

/** @var \DOMElement $elt */
/** @var \Dom\Element $elt */
$elt = $document->documentElement;
$myAttribute = new Chunk($elt);

/** @var \DOMElement $customAttrElt */
/** @var \Dom\Element $customAttrElt */
$customAttrElt = DOMDocumentFactory::fromString(
'<slate:custom xmlns:slate="http://technolutions.com/slate">customAttribute</slate:custom>',
)->documentElement;
Expand Down Expand Up @@ -115,7 +115,7 @@ public function testMarshallingElementOrdering(): void
'<cas:myAttribute xmlns:cas="http://www.yale.edu/tp/cas">myValue</cas:myAttribute>',
);

/** @var \DOMElement $elt */
/** @var \Dom\Element $elt */
$elt = $document->documentElement;
$myAttribute = new Chunk($elt);
$attributes = new Attributes($authenticationDate, $longTerm, $isFromNewLogin, [$myAttribute]);
Expand All @@ -128,7 +128,7 @@ public function testMarshallingElementOrdering(): void
$this->assertCount(1, $attributesElements);

// Test ordering of cas:attributes contents
/** @var \DOMElement[] $attributesElements */
/** @var \Dom\Element[] $attributesElements */
$attributesElements = XPath::xpQuery(
$attributesElement,
'./cas:authenticationDate/following-sibling::*',
Expand All @@ -148,7 +148,7 @@ public function testMarshallingElementOrdering(): void
*/
public function testFromXMLPopulatesTypedPropertiesAndFiltersStandardChildren(): void
{
/** @var \DOMElement $element */
/** @var \Dom\Element $element */
$element = self::$xmlRepresentation->documentElement;

$attributes = Attributes::fromXML($element);
Expand Down Expand Up @@ -193,7 +193,7 @@ public function testFromXMLWithOnlyExtensionAttributes(): void
</cas:attributes>
XML;

/** @var \DOMElement $element */
/** @var \Dom\Element $element */
$element = DOMDocumentFactory::fromString($xml)->documentElement;

$attributes = Attributes::fromXML($element);
Expand Down Expand Up @@ -225,7 +225,7 @@ public function testFromXMLWithDuplicateStandardChildThrows(): void
</cas:attributes>
XML;

/** @var \DOMElement $element */
/** @var \Dom\Element $element */
$element = DOMDocumentFactory::fromString($xml)->documentElement;

$this->expectException(MissingElementException::class);
Expand Down
32 changes: 16 additions & 16 deletions tests/Slate/XML/AuthenticationSuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
/** @var \DOMElement $firstNameElt */
/** @var \Dom\Element $firstNameElt */
$firstNameElt = DOMDocumentFactory::fromString(
'<cas:firstname xmlns:cas="http://www.yale.edu/tp/cas">Example</cas:firstname>',
)->documentElement;

$firstName = new Chunk($firstNameElt);

/** @var \DOMElement $lastNameElt */
/** @var \Dom\Element $lastNameElt */
$lastNameElt = DOMDocumentFactory::fromString(
'<cas:lastname xmlns:cas="http://www.yale.edu/tp/cas">User</cas:lastname>',
)->documentElement;
$lastName = new Chunk($lastNameElt);

/** @var \DOMElement $emailElt */
/** @var \Dom\Element $emailElt */
$emailElt = DOMDocumentFactory::fromString(
'<cas:email xmlns:cas="http://www.yale.edu/tp/cas">example-user@technolutions.com</cas:email>',
)->documentElement;
$email = new Chunk($emailElt);

/** @var \DOMElement $customAttrElt */
/** @var \Dom\Element $customAttrElt */
$customAttrElt = DOMDocumentFactory::fromString(
'<slate:custom xmlns:slate="http://technolutions.com/slate">customAttribute</slate:custom>',
)->documentElement;
Expand All @@ -100,22 +100,22 @@ public function testMarshalling(): void
new Proxy(StringValue::fromString('https://proxy1/pgtUrl')),
]);

/** @var \DOMElement $personElt */
/** @var \Dom\Element $personElt */
$personElt = DOMDocumentFactory::fromString(
// phpcs:ignore Generic.Files.LineLength
'<slate:person xmlns:slate="http://technolutions.com/slate">345d2e1b-65de-419c-96ce-e1866d4c57cd</slate:person>',
)->documentElement;

$person = new Chunk($personElt);

/** @var \DOMElement $roundElt */
/** @var \Dom\Element $roundElt */
$roundElt = DOMDocumentFactory::fromString(
'<slate:round xmlns:slate="http://technolutions.com/slate">Regular Decision</slate:round>',
)->documentElement;

$round = new Chunk($roundElt);

/** @var \DOMElement $refElt */
/** @var \Dom\Element $refElt */
$refElt = DOMDocumentFactory::fromString(
'<slate:ref xmlns:slate="http://technolutions.com/slate">774482874</slate:ref>',
)->documentElement;
Expand All @@ -139,20 +139,20 @@ public function testMarshalling(): void

public function testMarshallingElementOrdering(): void
{
/** @var \DOMElement $firstNameElt */
/** @var \Dom\Element $firstNameElt */
$firstNameElt = DOMDocumentFactory::fromString(
'<cas:firstname xmlns:cas="http://www.yale.edu/tp/cas">John</cas:firstname>',
)->documentElement;

$firstName = new Chunk($firstNameElt);

/** @var \DOMElement $lastNameElt */
/** @var \Dom\Element $lastNameElt */
$lastNameElt = DOMDocumentFactory::fromString(
'<cas:lastname xmlns:cas="http://www.yale.edu/tp/cas">Doe</cas:lastname>',
)->documentElement;
$lastName = new Chunk($lastNameElt);

/** @var \DOMElement $emailElt */
/** @var \Dom\Element $emailElt */
$emailElt = DOMDocumentFactory::fromString(
'<cas:email xmlns:cas="http://www.yale.edu/tp/cas">jdoe@example.org</cas:email>',
)->documentElement;
Expand All @@ -170,22 +170,22 @@ public function testMarshallingElementOrdering(): void
Proxy::fromString('https://proxy1/pgtUrl'),
]);

/** @var \DOMElement $personElt */
/** @var \Dom\Element $personElt */
$personElt = DOMDocumentFactory::fromString(
// phpcs:ignore Generic.Files.LineLength
'<slate:person xmlns:slate="http://technolutions.com/slate">345d2e1b-65de-419c-96ce-e1866d4c57cd</slate:person>',
)->documentElement;

$person = new Chunk($personElt);

/** @var \DOMElement $roundElt */
/** @var \Dom\Element $roundElt */
$roundElt = DOMDocumentFactory::fromString(
'<slate:round xmlns:slate="http://technolutions.com/slate">Regular Decision</slate:round>',
)->documentElement;

$round = new Chunk($roundElt);

/** @var \DOMElement $refElt */
/** @var \Dom\Element $refElt */
$refElt = DOMDocumentFactory::fromString(
'<slate:ref xmlns:slate="http://technolutions.com/slate">774482874</slate:ref>',
)->documentElement;
Expand All @@ -207,7 +207,7 @@ public function testMarshallingElementOrdering(): void
$this->assertCount(1, $authenticationSuccessElements);

// Test ordering of cas:authenticationSuccess contents
/** @var \DOMElement[] $authenticationSuccessElements */
/** @var \Dom\Element[] $authenticationSuccessElements */
$authenticationSuccessElements = XPath::xpQuery(
$authenticationSuccessElement,
'./cas:user/following-sibling::*',
Expand Down Expand Up @@ -236,7 +236,7 @@ public function testAuthenticationSuccessElementsContainOnlySlateChildren(): voi
dirname(__FILE__, 3) . '/resources/xml/slate_authenticationSuccess.xml',
);

/** @var \DOMElement $element */
/** @var \Dom\Element $element */
$element = $doc->documentElement;

$authenticationSuccess = AuthenticationSuccess::fromXML($element);
Expand Down Expand Up @@ -276,7 +276,7 @@ public function testAuthenticationSuccessElementsContainOnlySlateChildren(): voi
*/
public function testFromXMLNestedAttributesAreFilteredAndTyped(): void
{
/** @var \DOMElement $element */
/** @var \Dom\Element $element */
$element = self::$xmlRepresentation->documentElement;

$authenticationSuccess = AuthenticationSuccess::fromXML($element);
Expand Down
6 changes: 3 additions & 3 deletions tests/Slate/XML/ServiceResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace SimpleSAML\Slate\Test\XML;

use DOMDocument;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Slate\XML\AuthenticationSuccess;
use SimpleSAML\Slate\XML\ServiceResponse;
use SimpleSAML\XML\DOMDocumentFactory;

final class ServiceResponseTest extends TestCase
{
public function testFromXMLWithAuthenticationSuccessReturnsSlateAuthenticationSuccess(): void
{
$doc = new DOMDocument('1.0', 'UTF-8');
$doc = DOMDocumentFactory::create();

// Build <cas:serviceResponse> element with the correct namespace/localName
$serviceResponseElement = $doc->createElementNS(
Expand All @@ -33,8 +33,8 @@ public function testFromXMLWithAuthenticationSuccessReturnsSlateAuthenticationSu
$userElement = $doc->createElementNS(
ServiceResponse::getNamespaceURI(),
'cas:user',
'some-user',
);
$userElement->textContent = 'some-user';
$authSuccessElement->appendChild($userElement);

// Required child: <cas:attributes>...</cas:attributes>
Expand Down
Loading