Skip to content

Commit 4b85682

Browse files
committed
1.2.5
1 parent c5fcbb4 commit 4b85682

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
xml-constrcutor
22
===============
33

4+
v1.2.5 [2018-11-08]
5+
-------------------
6+
7+
- Fixed "no tag content" bug.
8+
49
v1.2.4 [2017-12-06]
510
-------------------
611

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"xml maker"
1212
],
1313
"license": "BSD-3-Clause",
14-
"version": "1.2.4",
14+
"version": "1.2.5",
1515
"authors": [
1616
{
17-
"name": "Vaseelie Belosloodcev",
18-
"email": "bupy765@gmail.com"
17+
"name": "Vasily Belosloodcev",
18+
"email": "vasily.belosloodcev@gmail.com"
1919
}
2020
],
2121
"require": {

tests/XmlConstructTest.php

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class XmlConstructTest extends TestCase
1212
{
13-
protected $in = [
13+
private $in1 = [
1414
[
1515
'tag' => 'root',
1616
'elements' => [
@@ -37,8 +37,27 @@ class XmlConstructTest extends TestCase
3737
],
3838
],
3939
];
40+
private $in2 = [
41+
[
42+
'tag' => 'root',
43+
'elements' => [
44+
[
45+
'tag' => 'tag1',
46+
// 'content' => 'content1', // no content
47+
],
48+
[
49+
'tag' => 'tag2',
50+
'content' => 'content2',
51+
],
52+
[
53+
'tag' => 'tag3',
54+
// 'content' => 'content3', // no content
55+
],
56+
],
57+
],
58+
];
4059

41-
public function testDefaultDocument()
60+
public function testDefaultDocument1()
4261
{
4362
$out1 = <<<XML
4463
<?xml version="1.0" encoding="UTF-8"?>
@@ -51,10 +70,25 @@ public function testDefaultDocument()
5170
</root>
5271
XML;
5372
$xml = new XmlConstructor;
54-
$out2 = $xml->fromArray($this->in)->toOutput();
73+
$out2 = $xml->fromArray($this->in1)->toOutput();
5574
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
5675
}
57-
76+
77+
public function testDefaultDocument2()
78+
{
79+
$out1 = <<<XML
80+
<?xml version="1.0" encoding="UTF-8"?>
81+
<root>
82+
<tag1/>
83+
<tag2>content2</tag2>
84+
<tag3/>
85+
</root>
86+
XML;
87+
$xml = new XmlConstructor;
88+
$out2 = $xml->fromArray($this->in2)->toOutput();
89+
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
90+
}
91+
5892
public function testWithoutStartDocument()
5993
{
6094
$out1 = <<<XML
@@ -67,7 +101,7 @@ public function testWithoutStartDocument()
67101
</root>
68102
XML;
69103
$xml = new XmlConstructor(['startDocument' => false]);
70-
$out2 = $xml->fromArray($this->in)->toOutput();
104+
$out2 = $xml->fromArray($this->in1)->toOutput();
71105
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
72106
}
73107

@@ -84,7 +118,7 @@ public function testCustomIndentString()
84118
</root>
85119
XML;
86120
$xml = new XmlConstructor(['indentString' => false]);
87-
$out2 = $xml->fromArray($this->in)->toOutput();
121+
$out2 = $xml->fromArray($this->in1)->toOutput();
88122
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
89123
}
90124

@@ -97,8 +131,12 @@ public function testError()
97131
$out2 = $xml->fromArray(['incorrect' => 'array'])->toOutput();
98132
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
99133
}
100-
101-
protected function prepare($xml)
134+
135+
/**
136+
* @param string $xml
137+
* @return string
138+
*/
139+
private function prepare($xml)
102140
{
103141
return preg_replace('/\s/', '', $xml);
104142
}

0 commit comments

Comments
 (0)