Skip to content

Commit 78e0db7

Browse files
committed
Support of PHP 8.2. Added some more tests.
1 parent 321a5d1 commit 78e0db7

File tree

6 files changed

+51
-10
lines changed

6 files changed

+51
-10
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- 7.4
2121
- 8.0
2222
- 8.1
23+
- 8.2
2324
steps:
2425
- uses: actions/checkout@v2
2526

CHANGELOG.md

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

4+
v1.3.4 [2022-12-11]
5+
---
6+
7+
- Support of PHP 8.2.
8+
- Added some more tests.
9+
410
v1.3.3 [2022-01-22]
511
---
612

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ xml-constructor
99

1010
The array-like constructor of XML document structure.
1111

12-
Supporting PHP from 5.6 up to 8.1.
12+
Supporting PHP from 5.6 up to 8.2.
1313

1414
Install
1515
---

src/XmlConstructor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function __construct(array $config = [])
7575
/**
7676
* Construct elements and texts from an array.
7777
* The array should contain an attribute's name in index part.
78-
* and a attribute's text in value part.
78+
* and an attribute's text in value part.
7979
*
8080
* @param array $in Contains tags, attributes and texts.
8181
* @return static
@@ -173,7 +173,7 @@ protected function configIndentString($string)
173173
{
174174
if ($string !== false) {
175175
$this->setIndent(true);
176-
parent::setIndentString($string);
176+
$this->setIndentString($string);
177177
}
178178
}
179179

tests/XmlConstructTest.php

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testDefaultDocument1()
8888
</tag3>
8989
</root>
9090
XML;
91-
$xml = new XmlConstructor;
91+
$xml = new XmlConstructor();
9292
$out2 = $xml->fromArray($this->in1)->toOutput();
9393
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
9494
}
@@ -103,12 +103,12 @@ public function testDefaultDocument2()
103103
<tag3/>
104104
</root>
105105
XML;
106-
$xml = new XmlConstructor;
106+
$xml = new XmlConstructor();
107107
$out2 = $xml->fromArray($this->in2)->toOutput();
108108
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
109109
}
110110

111-
public function testWithoutStartDocument()
111+
public function testWithoutStartDocument1()
112112
{
113113
$out1 = <<<XML
114114
<root>
@@ -123,8 +123,25 @@ public function testWithoutStartDocument()
123123
$out2 = $xml->fromArray($this->in1)->toOutput();
124124
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
125125
}
126+
127+
public function testWithoutStartDocument2()
128+
{
129+
$out1 = <<<XML
130+
<?xml version="1.1" encoding="ASCII"?>
131+
<root>
132+
<tag1 attr1="val1" attr2="val2"/>
133+
<tag2>content2</tag2>
134+
<tag3>
135+
<tag4>content4</tag4>
136+
</tag3>
137+
</root>
138+
XML;
139+
$xml = new XmlConstructor(['startDocument' => ['1.1', 'ASCII']]);
140+
$out2 = $xml->fromArray($this->in1)->toOutput();
141+
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
142+
}
126143

127-
public function testCustomIndentString()
144+
public function testCustomIndentString1()
128145
{
129146
$out1 = <<<XML
130147
<?xml version="1.0" encoding="UTF-8"?>
@@ -141,6 +158,23 @@ public function testCustomIndentString()
141158
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
142159
}
143160

161+
public function testCustomIndentString2()
162+
{
163+
$out1 = <<<XML
164+
<?xml version="1.0" encoding="UTF-8"?>
165+
<root>
166+
-<tag1 attr1="val1" attr2="val2"/>
167+
-<tag2>content2</tag2>
168+
-<tag3>
169+
--<tag4>content4</tag4>
170+
-</tag3>
171+
</root>
172+
XML;
173+
$xml = new XmlConstructor(['indentString' => '-']);
174+
$out2 = $xml->fromArray($this->in1)->toOutput();
175+
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
176+
}
177+
144178
/**
145179
* @since 1.3.0
146180
*/
@@ -163,7 +197,7 @@ public function testError()
163197
$out1 = <<<XML
164198
<?xml version="1.0" encoding="UTF-8"?>
165199
XML;
166-
$xml = new XmlConstructor;
200+
$xml = new XmlConstructor();
167201
$out2 = $xml->fromArray(['incorrect' => 'array'])->toOutput();
168202
$this->assertEquals($this->prepare($out1), $this->prepare($out2));
169203
}

workenv/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM php:8.1-cli-alpine
1+
FROM php:8.2-cli-alpine
22

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

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

0 commit comments

Comments
 (0)