Skip to content

Commit 992acde

Browse files
committed
1 parent 138d411 commit 992acde

File tree

2 files changed

+85
-85
lines changed

2 files changed

+85
-85
lines changed

Tests/JsonCrawlerTest.php

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function testAllThingsInStoreWithBrackets()
8484
public function testEscapedDoubleQuotesInFieldName()
8585
{
8686
$crawler = new JsonCrawler(<<<JSON
87-
{"a": {"b\\"c": 42}}
88-
JSON);
87+
{"a": {"b\\"c": 42}}
88+
JSON);
8989

9090
$result = $crawler->find('$["a"]["b\"c"]');
9191

@@ -95,8 +95,8 @@ public function testEscapedDoubleQuotesInFieldName()
9595
public function testMultipleKeysAtOnce()
9696
{
9797
$crawler = new JsonCrawler(<<<JSON
98-
{"a": {"b\\"c": 42}, "b": {"c": 43}}
99-
JSON);
98+
{"a": {"b\\"c": 42}, "b": {"c": 43}}
99+
JSON);
100100

101101
$result = $crawler->find("$['a', 'b', 3]");
102102

@@ -109,8 +109,8 @@ public function testMultipleKeysAtOnce()
109109
public function testMultipleKeysAtOnceOnArray()
110110
{
111111
$crawler = new JsonCrawler(<<<JSON
112-
[{"a": 1}, {"b": 2}, {"c": 3}, {"a,b,c": 5}, {"d": 4}]
113-
JSON);
112+
[{"a": 1}, {"b": 2}, {"c": 3}, {"a,b,c": 5}, {"d": 4}]
113+
JSON);
114114

115115
$result = $crawler->find("$[0, 2, 'a,b,c', -1]");
116116

@@ -221,8 +221,8 @@ public function testRecursiveWildcard()
221221
public function testSliceWithStep()
222222
{
223223
$crawler = new JsonCrawler(<<<JSON
224-
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
225-
JSON);
224+
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
225+
JSON);
226226

227227
$result = $crawler->find('$.a[1:5:2]');
228228
$this->assertSame([5, 2], $result);
@@ -231,8 +231,8 @@ public function testSliceWithStep()
231231
public function testNegativeSlice()
232232
{
233233
$crawler = new JsonCrawler(<<<JSON
234-
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
235-
JSON);
234+
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
235+
JSON);
236236

237237
$result = $crawler->find('$.a[-3:]');
238238

@@ -329,8 +329,8 @@ public function testNegativeIndicesEdgeCases()
329329
public function testBoundaryConditions()
330330
{
331331
$crawler = new JsonCrawler(<<<JSON
332-
{"a": [3, 5, 1, 2, 4, 6]}
333-
JSON);
332+
{"a": [3, 5, 1, 2, 4, 6]}
333+
JSON);
334334

335335
$result = $crawler->find('$.a[0:6]');
336336
$this->assertSame([3, 5, 1, 2, 4, 6], $result);
@@ -345,8 +345,8 @@ public function testBoundaryConditions()
345345
public function testFilterByValue()
346346
{
347347
$crawler = new JsonCrawler(<<<JSON
348-
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
349-
JSON);
348+
{"a": [3, 5, 1, 2, 4, 6, {"b": "j"}, {"b": "k"}, {"b": {}}, {"b": "kilo"}]}
349+
JSON);
350350

351351
$result = $crawler->find("$.a[?(@.b == 'kilo')]");
352352

@@ -560,8 +560,8 @@ public function testAcceptsJsonPath()
560560
public function testStarAsKey()
561561
{
562562
$crawler = new JsonCrawler(<<<JSON
563-
{"*": {"a": 1, "b": 2}, "something else": {"c": 3}}
564-
JSON);
563+
{"*": {"a": 1, "b": 2}, "something else": {"c": 3}}
564+
JSON);
565565

566566
$result = $crawler->find('$["*"]');
567567

@@ -779,59 +779,59 @@ public function testMixedQuoteTypes()
779779
private static function getBookstoreCrawler(): JsonCrawler
780780
{
781781
return new JsonCrawler(<<<JSON
782-
{
783-
"store": {
784-
"book": [
785-
{
786-
"category": "reference",
787-
"author": "Nigel Rees",
788-
"title": "Sayings of the Century",
789-
"price": 8.95
790-
},
791782
{
792-
"category": "fiction",
793-
"author": "Evelyn Waugh",
794-
"title": "Sword of Honour",
795-
"price": 12.99,
796-
"publisher": {
797-
"name": "my-publisher",
798-
"address": {
799-
"street": "1234 Elm St",
800-
"city": "Springfield",
801-
"state": "IL"
783+
"store": {
784+
"book": [
785+
{
786+
"category": "reference",
787+
"author": "Nigel Rees",
788+
"title": "Sayings of the Century",
789+
"price": 8.95
790+
},
791+
{
792+
"category": "fiction",
793+
"author": "Evelyn Waugh",
794+
"title": "Sword of Honour",
795+
"price": 12.99,
796+
"publisher": {
797+
"name": "my-publisher",
798+
"address": {
799+
"street": "1234 Elm St",
800+
"city": "Springfield",
801+
"state": "IL"
802+
}
803+
}
804+
},
805+
{
806+
"category": "fiction",
807+
"author": "Herman Melville",
808+
"title": "Moby Dick",
809+
"isbn": "0-553-21311-3",
810+
"price": 8.99,
811+
"extra": [42]
812+
},
813+
{
814+
"category": "fiction",
815+
"author": "J. R. R. Tolkien",
816+
"title": "The Lord of the Rings",
817+
"isbn": "0-395-19395-8",
818+
"price": 22.99
819+
}
820+
],
821+
"bicycle": {
822+
"color": "red",
823+
"price": 399
802824
}
803825
}
804-
},
805-
{
806-
"category": "fiction",
807-
"author": "Herman Melville",
808-
"title": "Moby Dick",
809-
"isbn": "0-553-21311-3",
810-
"price": 8.99,
811-
"extra": [42]
812-
},
813-
{
814-
"category": "fiction",
815-
"author": "J. R. R. Tolkien",
816-
"title": "The Lord of the Rings",
817-
"isbn": "0-395-19395-8",
818-
"price": 22.99
819826
}
820-
],
821-
"bicycle": {
822-
"color": "red",
823-
"price": 399
824-
}
825-
}
826-
}
827-
JSON);
827+
JSON);
828828
}
829829

830830
private static function getSimpleCollectionCrawler(): JsonCrawler
831831
{
832832
return new JsonCrawler(<<<JSON
833-
{"a": [3, 5, 1, 2, 4, 6]}
834-
JSON);
833+
{"a": [3, 5, 1, 2, 4, 6]}
834+
JSON);
835835
}
836836

837837
private static function getUnicodeDocumentCrawler(): JsonCrawler

Tests/JsonPathUtilsTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public function testReduceWithBasicProperty()
4949
fclose($resource);
5050

5151
$this->assertSame(<<<JSON
52-
{"book": [
53-
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
54-
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
55-
]}
56-
JSON, $reduced['json']);
52+
{"book": [
53+
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
54+
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
55+
]}
56+
JSON, $reduced['json']);
5757
$this->assertEquals([new JsonPathToken(TokenType::Name, 'book')], $reduced['tokens']);
5858
}
5959

@@ -70,11 +70,11 @@ public function testReduceUntilFilter()
7070
fclose($resource);
7171

7272
$this->assertSame(<<<JSON
73-
{"book": [
74-
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
75-
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
76-
]}
77-
JSON, $reduced['json']);
73+
{"book": [
74+
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
75+
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
76+
]}
77+
JSON, $reduced['json']);
7878
$this->assertEquals([new JsonPathToken(TokenType::Bracket, '?(@.book.author == "Nigel Rees")')], $reduced['tokens']);
7979
}
8080

@@ -112,11 +112,11 @@ public function testDoesNotReduceOnArraySlice()
112112
fclose($resource);
113113

114114
$this->assertSame(<<<JSON
115-
[
116-
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
117-
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
118-
]
119-
JSON, $reduced['json'], 'reduce to "book", but not further');
115+
[
116+
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
117+
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
118+
]
119+
JSON, $reduced['json'], 'reduce to "book", but not further');
120120
$this->assertEquals([
121121
new JsonPathToken(TokenType::Bracket, '1:2'),
122122
], $reduced['tokens']);
@@ -154,11 +154,11 @@ public function testDoesNotReduceOnUnknownIndex()
154154
fclose($resource);
155155

156156
$this->assertSame(<<<JSON
157-
[
158-
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
159-
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
160-
]
161-
JSON, $reduced['json'], 'reduce to "book", but not further');
157+
[
158+
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
159+
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
160+
]
161+
JSON, $reduced['json'], 'reduce to "book", but not further');
162162
$this->assertEquals([
163163
new JsonPathToken(TokenType::Bracket, '123'),
164164
new JsonPathToken(TokenType::Name, 'title'),
@@ -171,11 +171,11 @@ public function testDoesNotReduceOnUnknownIndex()
171171
private static function provideJsonResource(): mixed
172172
{
173173
$json = <<<'JSON'
174-
{"store": {"book": [
175-
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
176-
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
177-
]}}
178-
JSON;
174+
{"store": {"book": [
175+
{"category": "reference", "author": "Nigel Rees", "title": "Sayings", "price": 8.95},
176+
{"category": "fiction", "author": "Evelyn Waugh", "title": "Sword", "price": 12.99}
177+
]}}
178+
JSON;
179179

180180
$resource = fopen('php://memory', 'r+');
181181
fwrite($resource, $json);

0 commit comments

Comments
 (0)