Skip to content

Commit 927a822

Browse files
committed
Fix bug
1 parent 1c98a2f commit 927a822

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/QNameElementTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function fromXML(DOMElement $xml): static
110110
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
111111

112112
list($prefix, $localName) = self::parseQName($xml->textContent);
113-
if ($localName === null) {
113+
if ($prefix === null) {
114114
// We don't have a prefixed value here; use target namespace
115115
$namespace = $xml->lookupNamespaceUri(null);
116116
} else {

tests/XML/QNameElementTraitTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,17 @@ public function testUnmarshalling(): void
8383
$this->assertEquals('env:Sender', $qnameElement->getContent());
8484
$this->assertEquals('http://www.w3.org/2003/05/soap-envelope', $qnameElement->getContentNamespaceUri());
8585
}
86+
87+
88+
/**
89+
*/
90+
public function testUnmarshallingNonNamepacedQualifiedName(): void
91+
{
92+
$qnameElement = QNameElement::fromXML(DOMDocumentFactory::fromString(
93+
'<ssp:QNameElement xmlns:ssp="urn:x-simplesamlphp:namespace">Sender</ssp:QNameElement>'
94+
)->documentElement);
95+
96+
$this->assertEquals('Sender', $qnameElement->getContent());
97+
$this->assertNull($qnameElement->getContentNamespaceUri());
98+
}
8699
}

0 commit comments

Comments
 (0)