Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70a7d26

Browse files
committed
Reproducing test case for zendframework#6279
1 parent c3d3a55 commit 70a7d26

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<config>
3+
<one>bazbat</one>
4+
<one foo="bar">bazbat</one>
5+
</config>

tests/ZendTest/Config/Reader/XmlTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,29 @@ public function testZF300_ArraysWithMultipleChildren()
9696
$this->assertEquals('2', $config['six']['seven'][1]['nine']);
9797
$this->assertEquals('3', $config['six']['seven'][2]['nine']);
9898
}
99+
100+
/**
101+
* @group zf6279
102+
*/
103+
public function testElementWithBothAttributesAndAStringValueIsProcessedCorrectly()
104+
{
105+
$this->reader = new Xml();
106+
$arrayXml = $this->reader->fromFile($this->getTestAssetPath('attributes'));
107+
$this->assertArrayHasKey('one', $arrayXml);
108+
$this->assertInternalType('array', $arrayXml['one']);
109+
110+
// No attribute + text value == string
111+
$this->assertArrayHasKey(0, $arrayXml['one']);
112+
$this->assertEquals('bazbat', $arrayXml['one'][0]);
113+
114+
// Attribute(s) + text value == array
115+
$this->assertArrayHasKey(1, $arrayXml['one']);
116+
$this->assertInternalType('array', $arrayXml['one'][1]);
117+
// Attributes stored in named array keys
118+
$this->assertArrayHasKey('foo', $arrayXml['one'][1]);
119+
$this->assertEquals('bar', $arrayXml['one'][1]['foo']);
120+
// Element value stored in special key '_'
121+
$this->assertArrayHasKey('_', $arrayXml['one'][1]);
122+
$this->assertEquals('bazbat', $arrayXml['one'][1]['_']);
123+
}
99124
}

0 commit comments

Comments
 (0)