-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path026.phpt
93 lines (90 loc) · 1.56 KB
/
026.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--TEST--
Test greater-than number comparison condition with float compared to numbers and numerical strings
--SKIPIF--
<?php if (!extension_loaded("jsonpath")) print "skip"; ?>
--FILE--
<?php
$data = [
[
'product' => 'tomato',
'quantity' => '4',
],
[
'product' => 'apple',
'quantity' => '1',
],
[
'product' => 'pear',
'quantity' => 2,
],
[
'product' => 'banana',
'quantity' => '0',
],
[
'product' => 'cucumber',
'quantity' => 0,
],
[
'product' => 'coconut',
'quantity' => '0.5',
],
[
'product' => 'carrot',
'quantity' => '3',
],
[
'product' => 'cauliflower',
'quantity' => '-4',
],
[
'product' => 'watermelon',
'quantity' => '-2',
],
[
'product' => 'asparagus',
'quantity' => '-2.5',
],
];
$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$[?(@.quantity > 0.2)]");
var_dump($result);
?>
--EXPECT--
array(5) {
[0]=>
array(2) {
["product"]=>
string(6) "tomato"
["quantity"]=>
string(1) "4"
}
[1]=>
array(2) {
["product"]=>
string(5) "apple"
["quantity"]=>
string(1) "1"
}
[2]=>
array(2) {
["product"]=>
string(4) "pear"
["quantity"]=>
int(2)
}
[3]=>
array(2) {
["product"]=>
string(7) "coconut"
["quantity"]=>
string(3) "0.5"
}
[4]=>
array(2) {
["product"]=>
string(6) "carrot"
["quantity"]=>
string(1) "3"
}
}