Skip to content

Commit ce60fa7

Browse files
committed
[TASK] Improve XmlHander unit testing
1 parent b2d4ff2 commit ce60fa7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Tests/Unit/Handler/XmlHandlerTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ public static function getValueSuccessProvider(): array
7676
],
7777
'result' => 'foo',
7878
],
79+
'attribute value' => [
80+
'structure' => '<item id="1">foo</item>',
81+
'configuration' => [
82+
'field' => 'item',
83+
'attribute' => 'id',
84+
],
85+
'result' => '1',
86+
],
7987
'xpath value' => [
8088
'structure' => '<item><bar>foo</bar></item>',
8189
'configuration' => [
@@ -124,7 +132,21 @@ public static function getSubstructureProvider(): array
124132
return [
125133
[
126134
// Test elements are always wrapped in an <item> tag
127-
'structure' => '<items><item><foo>me</foo><bar><who>you</who></bar><baz>them</baz></item><item><foo>me2</foo><bar><who>you2</who></bar><baz>them2</baz></item></items>',
135+
'structure' => <<<'EOF'
136+
<items>
137+
<item>
138+
<foo id="1">me</foo>
139+
<bar><who>you</who></bar>
140+
<baz>them</baz>
141+
</item>
142+
<item>
143+
<foo id="2">me2</foo>
144+
<bar><who>you2</who></bar>
145+
<baz>them2</baz>
146+
</item>
147+
</items>
148+
EOF
149+
,
128150
'configuration' => [
129151
'first' => [
130152
'field' => 'foo',
@@ -135,15 +157,21 @@ public static function getSubstructureProvider(): array
135157
'third' => [
136158
'field' => 'unknown',
137159
],
160+
'fourth' => [
161+
'field' => 'foo',
162+
'attribute' => 'id',
163+
],
138164
],
139165
'result' => [
140166
[
141167
'first' => 'me',
142168
'second' => 'you',
169+
'fourth' => '1',
143170
],
144171
[
145172
'first' => 'me2',
146173
'second' => 'you2',
174+
'fourth' => '2',
147175
],
148176
],
149177
],

0 commit comments

Comments
 (0)