Skip to content

Commit

Permalink
Merge 78e0db7 into 321a5d1
Browse files Browse the repository at this point in the history
  • Loading branch information
bupy7 committed Dec 11, 2022
2 parents 321a5d1 + 78e0db7 commit 057b7c0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- 7.4
- 8.0
- 8.1
- 8.2
steps:
- uses: actions/checkout@v2

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
xml-constrcutor
===

v1.3.4 [2022-12-11]
---

- Support of PHP 8.2.
- Added some more tests.

v1.3.3 [2022-01-22]
---

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ xml-constructor

The array-like constructor of XML document structure.

Supporting PHP from 5.6 up to 8.1.
Supporting PHP from 5.6 up to 8.2.

Install
---
Expand Down
4 changes: 2 additions & 2 deletions src/XmlConstructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(array $config = [])
/**
* Construct elements and texts from an array.
* The array should contain an attribute's name in index part.
* and a attribute's text in value part.
* and an attribute's text in value part.
*
* @param array $in Contains tags, attributes and texts.
* @return static
Expand Down Expand Up @@ -173,7 +173,7 @@ protected function configIndentString($string)
{
if ($string !== false) {
$this->setIndent(true);
parent::setIndentString($string);
$this->setIndentString($string);
}
}

Expand Down
44 changes: 39 additions & 5 deletions tests/XmlConstructTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testDefaultDocument1()
</tag3>
</root>
XML;
$xml = new XmlConstructor;
$xml = new XmlConstructor();
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}
Expand All @@ -103,12 +103,12 @@ public function testDefaultDocument2()
<tag3/>
</root>
XML;
$xml = new XmlConstructor;
$xml = new XmlConstructor();
$out2 = $xml->fromArray($this->in2)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testWithoutStartDocument()
public function testWithoutStartDocument1()
{
$out1 = <<<XML
<root>
Expand All @@ -123,8 +123,25 @@ public function testWithoutStartDocument()
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testWithoutStartDocument2()
{
$out1 = <<<XML
<?xml version="1.1" encoding="ASCII"?>
<root>
<tag1 attr1="val1" attr2="val2"/>
<tag2>content2</tag2>
<tag3>
<tag4>content4</tag4>
</tag3>
</root>
XML;
$xml = new XmlConstructor(['startDocument' => ['1.1', 'ASCII']]);
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testCustomIndentString()
public function testCustomIndentString1()
{
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -141,6 +158,23 @@ public function testCustomIndentString()
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

public function testCustomIndentString2()
{
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
-<tag1 attr1="val1" attr2="val2"/>
-<tag2>content2</tag2>
-<tag3>
--<tag4>content4</tag4>
-</tag3>
</root>
XML;
$xml = new XmlConstructor(['indentString' => '-']);
$out2 = $xml->fromArray($this->in1)->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}

/**
* @since 1.3.0
*/
Expand All @@ -163,7 +197,7 @@ public function testError()
$out1 = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
XML;
$xml = new XmlConstructor;
$xml = new XmlConstructor();
$out2 = $xml->fromArray(['incorrect' => 'array'])->toOutput();
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
}
Expand Down
4 changes: 2 additions & 2 deletions workenv/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM php:8.1-cli-alpine
FROM php:8.2-cli-alpine

RUN apk add --no-cache $PHPIZE_DEPS
RUN apk add --no-cache $PHPIZE_DEPS && apk add --update --no-cache linux-headers

RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
Expand Down

0 comments on commit 057b7c0

Please sign in to comment.