Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bupy7 committed Nov 8, 2018
1 parent c5fcbb4 commit 4b85682
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
xml-constrcutor
===============

v1.2.5 [2018-11-08]
-------------------

- Fixed "no tag content" bug.

v1.2.4 [2017-12-06]
-------------------

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"xml maker"
],
"license": "BSD-3-Clause",
"version": "1.2.4",
"version": "1.2.5",
"authors": [
{
"name": "Vaseelie Belosloodcev",
"email": "bupy765@gmail.com"
"name": "Vasily Belosloodcev",
"email": "vasily.belosloodcev@gmail.com"
}
],
"require": {
Expand Down
54 changes: 46 additions & 8 deletions tests/XmlConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class XmlConstructTest extends TestCase
{
protected $in = [
private $in1 = [
[
'tag' => 'root',
'elements' => [
Expand All @@ -37,8 +37,27 @@ class XmlConstructTest extends TestCase
],
],
];
private $in2 = [
[
'tag' => 'root',
'elements' => [
[
'tag' => 'tag1',
// 'content' => 'content1', // no content
],
[
'tag' => 'tag2',
'content' => 'content2',
],
[
'tag' => 'tag3',
// 'content' => 'content3', // no content
],
],
],
];

public function testDefaultDocument()
public function testDefaultDocument1()
{
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -51,10 +70,25 @@ public function testDefaultDocument()
</root>
XML;
$xml = new XmlConstructor;
$out2 = $xml->fromArray($this->in)->toOutput();
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}


public function testDefaultDocument2()
{
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag1/>
<tag2>content2</tag2>
<tag3/>
</root>
XML;
$xml = new XmlConstructor;
$out2 = $xml->fromArray($this->in2)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testWithoutStartDocument()
{
$out1 = <<<XML
Expand All @@ -67,7 +101,7 @@ public function testWithoutStartDocument()
</root>
XML;
$xml = new XmlConstructor(['startDocument' => false]);
$out2 = $xml->fromArray($this->in)->toOutput();
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

Expand All @@ -84,7 +118,7 @@ public function testCustomIndentString()
</root>
XML;
$xml = new XmlConstructor(['indentString' => false]);
$out2 = $xml->fromArray($this->in)->toOutput();
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

Expand All @@ -97,8 +131,12 @@ public function testError()
$out2 = $xml->fromArray(['incorrect' => 'array'])->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

protected function prepare($xml)

/**
* @param string $xml
* @return string
*/
private function prepare($xml)
{
return preg_replace('/\s/', '', $xml);
}
Expand Down

0 comments on commit 4b85682

Please sign in to comment.