Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Oct 11, 2022
1 parent 1c98a2f commit 927a822
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/QNameElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function fromXML(DOMElement $xml): static
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);

list($prefix, $localName) = self::parseQName($xml->textContent);
if ($localName === null) {
if ($prefix === null) {
// We don't have a prefixed value here; use target namespace
$namespace = $xml->lookupNamespaceUri(null);
} else {
Expand Down
13 changes: 13 additions & 0 deletions tests/XML/QNameElementTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,17 @@ public function testUnmarshalling(): void
$this->assertEquals('env:Sender', $qnameElement->getContent());
$this->assertEquals('http://www.w3.org/2003/05/soap-envelope', $qnameElement->getContentNamespaceUri());
}


/**
*/
public function testUnmarshallingNonNamepacedQualifiedName(): void
{
$qnameElement = QNameElement::fromXML(DOMDocumentFactory::fromString(
'<ssp:QNameElement xmlns:ssp="urn:x-simplesamlphp:namespace">Sender</ssp:QNameElement>'
)->documentElement);

$this->assertEquals('Sender', $qnameElement->getContent());
$this->assertNull($qnameElement->getContentNamespaceUri());
}
}

0 comments on commit 927a822

Please sign in to comment.