Skip to content

Commit a8bfe87

Browse files
committed
Test for issue #125
1 parent 58fb6e9 commit a8bfe87

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
.vscode
23
/vendor/
34
composer.lock
45
*.cache

test/JsonMachineTest/ItemsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,26 @@ public function testCountViaIteratorCount()
146146

147147
$this->assertSame(3, iterator_count($items));
148148
}
149+
150+
public function testIssue125()
151+
{
152+
$data = '{
153+
"code": "some value",
154+
"key_one": 1,
155+
"key_two": [1]
156+
}';
157+
158+
$pointer = Items::fromString($data, ['pointer' => '/key_one']);
159+
$result = iterator_to_array($pointer);
160+
$this->assertSame([
161+
'key_one' => 1,
162+
], $result);
163+
164+
165+
$pointer = Items::fromString($data, ['pointer' => '/key_two']);
166+
$result = iterator_to_array($pointer);
167+
$this->assertSame([
168+
0 => 1,
169+
], $result);
170+
}
149171
}

0 commit comments

Comments
 (0)