-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed handling of elements from foreign namespaces in values object
When encountering an element from another namespace the value object parser does skip the opening element. However when it encounters the closing element it did handle it like it was the closing element of the one being processed. This commit and unit test fixes the issue by ignoring the element completely
- Loading branch information
1 parent
43cea9f
commit 775c2a8
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,43 @@ public function testDeserializeValueObjectIgnoredElement(): void | |
); | ||
} | ||
|
||
public function testDeserializeValueObjectIgnoredNamespace(): void | ||
{ | ||
$input = <<<XML | ||
<?xml version="1.0"?> | ||
<foo xmlns="urn:foo" xmlns:alien="urn:example.com"> | ||
<firstName>Harry</firstName> | ||
<alien:email>[email protected]</alien:email> | ||
<lastName>Turtle</lastName> | ||
</foo> | ||
XML; | ||
|
||
$reader = new Reader(); | ||
$reader->xml($input); | ||
$reader->elementMap = [ | ||
'{urn:foo}foo' => function (Reader $reader) { | ||
return valueObject($reader, 'Sabre\\Xml\\Deserializer\\TestVo', 'urn:foo'); | ||
}, | ||
]; | ||
|
||
$output = $reader->parse(); | ||
|
||
$vo = new TestVo(); | ||
$vo->firstName = 'Harry'; | ||
$vo->lastName = 'Turtle'; | ||
|
||
$expected = [ | ||
'name' => '{urn:foo}foo', | ||
'value' => $vo, | ||
'attributes' => [], | ||
]; | ||
|
||
$this->assertEquals( | ||
$expected, | ||
$output | ||
); | ||
} | ||
|
||
public function testDeserializeValueObjectAutoArray(): void | ||
{ | ||
$input = <<<XML | ||
|