Skip to content

Commit 9dab45c

Browse files
authored
Merge pull request #19 from gaarf/running-tests
fix tests / CI
2 parents 40ae46e + 0b79cff commit 9dab45c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ jobs:
3838
run: composer phpstan
3939

4040
- name: Run tests
41-
run: bash tests/test.sh
41+
run: tests/test.sh

src/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function domNodeToArray($node)
3636
if (!isset($output[$t])) {
3737
$output[$t] = [];
3838
}
39-
if (empty($v)) {
39+
if (is_array($v) && empty($v)) {
4040
$v = '';
4141
}
4242
$output[$t][] = $v;

tests/test.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ EOD;
3636

3737
$expected = array(
3838

39-
"@root" => 'tv',
40-
41-
"@attributes" => array( "type" => "cartoon" ),
42-
4339
"show" => array(
4440

4541
array(
@@ -82,7 +78,11 @@ $expected = array(
8278
)
8379
)
8480

85-
)
81+
),
82+
83+
"@attributes" => array( "type" => "cartoon" ),
84+
85+
"@root" => 'tv',
8686
);
8787

8888
$result = \Gaarf\XmlToPhp\Convertor::covertToArray($xmlstr);
@@ -92,7 +92,8 @@ if ($result == $expected) {
9292
} else {
9393
prettyPrint('Result', 'FAILURE :-(');
9494
prettyPrint('Input', $xmlstr);
95-
prettyPrint('Expected', $expected);
96-
prettyPrint('Output', $result);
95+
prettyPrint('Expected', $expected);
96+
prettyPrint('Output', $result);
9797
prettyPrint('Result', 'FAILURE :-(');
98+
exit(1);
9899
}

0 commit comments

Comments
 (0)