Completed
Push — master ( 5844b8...ad296e )
by Russell
02:26
created

JSONTextQueryTest::testQueryWithInvalidArgs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package silverstripe-jsontext
5
 * @subpackage fields
6
 * @author Russell Michell <[email protected]>
7
 * @todo Add tests where source data is a JSON array, not just a JSON object
8
 * 
9
 *
10
 */
11
12
use JSONText\Fields\JSONText;
13
use JSONText\Exceptions;
14
15
class JSONTextQueryTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $fixtures = [
21
        'array'     => 'tests/fixtures/json/array.json',
22
        'object'    => 'tests/fixtures/json/object.json',
23
        'invalid'   => 'tests/fixtures/json/invalid.json'
24
    ];
25
26
    /**
27
     * @var \JSONText\Fields\JSONText
28
     */
29
    protected $sut;
30
31
    /**
32
     * JSONTextTest constructor.
33
     * 
34
     * Modify fixtures property to be able to run on PHP <5.6 without use of constant in class property which 5.6+ allows
35
     */
36
    public function __construct()
37
    {
38 View Code Duplication
        foreach($this->fixtures as $name => $path) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
            $this->fixtures[$name] = MODULE_DIR . '/' . $path;
40
        }
41
    }
42
43
    /**
44
     * Setup the System Under Test for this test suite.
45
     */
46
    public function setUp()
47
    {
48
        parent::setUp();
49
50
        $this->sut = JSONText::create('MyJSON');
51
    }
52
53
    /**
54
     * Tests query() by means of the integer Postgres Int match operator: '->'
55
     * 
56
     * @todo Use same source data instead of repeating..
57
     */
58
    public function testQueryWithMatchOnInt()
59
    {
60
        $field = $this->sut;
61
        
62
        // Data Source: Array
63
        // Return Type: ARRAY
64
        // Operator: "->" (Int)
65
        $field->setReturnType('array');
66
        $field->setValue($this->getFixture('array'));
67
        $this->assertEquals([2 => 'trabant'], $field->query('->', 2));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
        
69
        // Data Source: Array
70
        // Return Type: JSON
71
        // Operator: "->" (Int)
72
        $field->setReturnType('json');
73
        $field->setValue($this->getFixture('array'));
74
        $this->assertEquals('{"2":"trabant"}', $field->query('->', 2));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
        $this->assertEquals('{"5":101}', $field->query('->', 5));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
        
77
        // Data Source: Array
78
        // Return Type: SILVERSTRIPE
79
        // Operator: "->" (Int)
80
        // SS Type: Float
81
        $field->setReturnType('silverstripe');
82
        $field->setValue($this->getFixture('array'));
83
        $this->assertInternalType('array', $field->query('->', 3));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
84
        $this->assertInstanceOf('Float', $field->query('->', 3)[3]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
85
        $this->assertEquals(44.6, $field->query('->', 3)[3]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
86
87
        // Data Source: Array
88
        // Return Type: SILVERSTRIPE
89
        // Operator: "->" (Int)
90
        // SS Type: Boolean
91
        $field->setReturnType('silverstripe');
92
        $field->setValue($this->getFixture('array'));
93
        $this->assertInternalType('array', $field->query('->', 1));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
94
        $this->assertInstanceOf('Boolean', $field->query('->', 1)[1]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
        $this->assertEquals(1, $field->query('->', 1)[1]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
96
97
        // Data Source: Array
98
        // Return Type: SILVERSTRIPE
99
        // Operator: "->" (Int)
100
        // SS Type: Int
101
        $field->setReturnType('silverstripe');
102
        $field->setValue($this->getFixture('array'));
103
        $this->assertInternalType('array', $field->query('->', 5));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
        $this->assertInstanceOf('Int', $field->query('->', 5)[5]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
105
        $this->assertEquals(101, $field->query('->', 5)[5]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
106
107
        // Data Source: Array
108
        // Return Type: SILVERSTRIPE
109
        // Operator: "->" (Int)
110
        // SS Type: Varchar
111
        $field->setReturnType('silverstripe');
112
        $field->setValue($this->getFixture('array'));
113
        $this->assertInternalType('array', $field->query('->', 4));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
114
        $this->assertInstanceOf('Varchar', $field->query('->', 4)[4]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
        $this->assertEquals('buick', $field->query('->', 4)[4]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
116
117
        // Test: Empty #1
118
        $field->setReturnType('array');
119
        $field->setValue('');
120
        $this->assertInternalType('array', $field->query('->', 3));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
121
        $this->assertCount(0, $field->query('->', 3));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
122
123
        // Test: Invalid #1
124
        $field->setReturnType('array');
125
        $field->setValue('["morris"]');
126
        $this->assertEquals([], $field->query('->', 17));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
127
    }
128
129
    /**
130
     * Tests query() by means of the integer Postgres String match operator: '->>'
131
     */
132
    public function testQueryWithMatchOnStr()
133
    {
134
        $field = $this->sut;
135
        
136
        // Data Source: Object
137
        // Return Type: ARRAY
138
        // Operator: "->>" (String)
139
        $field->setReturnType('array');
140
        $field->setValue($this->getFixture('object'));
141
        $this->assertEquals(['Subaru' => 'Impreza'], $field->query('->>', 'Subaru'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
142
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
143
            ['japanese' => ['fast' => ['Subaru' => 'Impreza'], 'slow' => ['Honda' => 'Civic']]],
144
            $field->query('->>', 'japanese')
145
        );
146
147
        // Data Source: Object
148
        // Return Type: JSON
149
        // Operator: "->>" (String)
150
        $field->setReturnType('json');
151
        $field->setValue($this->getFixture('object'));
152
        $this->assertEquals('{"Subaru":"Impreza"}', $field->query('->>', 'Subaru'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
153
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
154
            '{"japanese":{"fast":{"Subaru":"Impreza"},"slow":{"Honda":"Civic"}}}',
155
            $field->query('->>', 'japanese')
156
        );
157
158
        // Data Source: Object
159
        // Return Type: SilverStripe
160
        // Operator: "->>" (String)
161
        // SS Type: Varchar
162
        $field->setReturnType('silverstripe');
163
        $field->setValue($this->getFixture('object'));
164
        $this->assertInternalType('array', $field->query('->>', 'Subaru'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
165
        $this->assertInstanceOf('Varchar', $field->query('->>', 'Subaru')['Subaru']);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
166
        $this->assertEquals('Impreza', $field->query('->>', 'Subaru')['Subaru']->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
167
168
        // Data Source: Object
169
        // Return Type: SilverStripe
170
        // Operator: "->>" (String)
171
        // SS Type: Boolean
172
        $field->setReturnType('silverstripe');
173
        $field->setValue($this->getFixture('object'));
174
        $this->assertInternalType('array', $field->query('->>', 'beer tastes good'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
175
        $this->assertInstanceOf('Boolean', $field->query('->>', 'beer tastes good')['beer tastes good']);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
176
        $this->assertEquals(1, $field->query('->>', 'beer tastes good')['beer tastes good']->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
177
178
        // Data Source: Object
179
        // Return Type: SilverStripe
180
        // Operator: "->>" (String)
181
        // SS Type: Float
182
        $field->setReturnType('silverstripe');
183
        $field->setValue($this->getFixture('object'));
184
        $this->assertInternalType('array', $field->query('->>', 'how sure are you'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
185
        $this->assertInstanceOf('Float', $field->query('->>', 'how sure are you')['how sure are you']);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
186
        $this->assertEquals(99.99, $field->query('->>', 'how sure are you')['how sure are you']->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
187
188
        // Data Source: Object
189
        // Return Type: SilverStripe
190
        // Operator: "->>" (String)
191
        // SS Type: Int
192
        $field->setReturnType('silverstripe');
193
        $field->setValue($this->getFixture('object'));
194
        $this->assertInternalType('array', $field->query('->>', 'how high'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
195
        $this->assertInstanceOf('Int', $field->query('->>', 'how high')['how high']);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
196
        $this->assertEquals(6, $field->query('->>', 'how high')['how high']->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
197
198
        // Data Source: Object
199
        // Return Type: SilverStripe
200
        // Operator: "->>" (String)
201
        // SS Type: N/A Nested sub-array example, expect an array
202
        $field->setReturnType('silverstripe');
203
        $field->setValue($this->getFixture('object'));
204
        $this->assertInternalType('array', $field->query('->>', 'planes')['planes']);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
205
        $this->assertInternalType('array', $field->query('->>', 'planes')['planes']['russian']);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
206
        $this->assertCount(2, $field->query('->>', 'planes')['planes']['russian']);
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
207
        $this->assertInstanceOf('Varchar', $field->query('->>', 'planes')['planes']['russian'][0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
208
        $this->assertInstanceOf('Varchar', $field->query('->>', 'planes')['planes']['russian'][1]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
209
210
        // Test: Empty #1
211
        $field->setReturnType('array');
212
        $field->setValue('');
213
        $this->assertInternalType('array', $field->query('->>', 'planes'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
214
        $this->assertCount(0, $field->query('->', 3));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
215
216
        // Test: Empty #2
217
        $field->setReturnType('array');
218
        $field->setValue('["morris"]');
219
        $this->assertEquals([], $field->query('->', 17));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
220
221
        // Test: Invalid #1
222
        $field->setReturnType('array');
223
        $field->setValue('["trabant"]');
224
        $this->assertEquals([], $field->query('->', 1));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
225
    }
226
227
    /**
228
     * Tests query() by means of the Postgres path-match operator: '#>'
229
     */
230
    public function testQueryWithMatchOnPath()
231
    {
232
        $field = $this->sut;
233
        
234
        // Data Source: Object
235
        // Return Type: ARRAY
236
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
237
        // Expect: Array due to duplicate keys in different parts of the source data
238
        $field->setReturnType('array');
239
        $field->setValue($this->getFixture('object'));
240
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
241
            [['Subaru' => 'Impreza'],['Kawasaki' => 'KR1S250']],
242
            $field->query('#>', '{"japanese":"fast"}')
243
        );
244
245
        // Data Source: Object
246
        // Return Type: JSON
247
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
248
        // Expect: Array due to duplicate keys in different parts of the source data
249
        $field->setReturnType('json');
250
        $field->setValue($this->getFixture('object'));
251
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
252
            '[{"Subaru":"Impreza"},{"Kawasaki":"KR1S250"}]',
253
            $field->query('#>', '{"japanese":"fast"}')
254
        );
255
256
        // Data Source: Object
257
        // Return Type: SILVERSTRIPE
258
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
259
        // Expect: Array due to duplicate keys in different parts of the source data
260
        $field->setReturnType('silverstripe');
261
        $field->setValue($this->getFixture('object'));
262
        $this->assertInternalType('array', $field->query('#>', '{"japanese":"fast"}'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
263
        $this->assertCount(2, $field->query('#>', '{"japanese":"fast"}'));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
264
        
265
        $one = $field->query('#>', '{"japanese":"fast"}')[0];
266
        $two = $field->query('#>', '{"japanese":"fast"}')[1];
267
        
268
        $this->assertInternalType('array', $one);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
269
        $this->assertInternalType('array', $two);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
270
        $this->assertInstanceOf('Varchar', array_values($one)[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
271
        $this->assertInstanceOf('Varchar', array_values($two)[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
272
        $this->assertEquals('Impreza', array_values($one)[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
273
        $this->assertEquals('KR1S250', array_values($two)[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
274
275
        // Data Source: Object
276
        // Return Type: ARRAY
277
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
278
        // Expect: Direct scalar comparison assertion
279
        $field->setReturnType('array');
280
        $field->setValue($this->getFixture('object'));
281
        $this->assertEquals(['airbus'], $field->query('#>', '{"planes":"french"}'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
282
283
        // Data Source: Object
284
        // Return Type: JSON
285
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
286
        // Expect: Direct scalar comparison assertion
287
        $field->setReturnType('json');
288
        $field->setValue($this->getFixture('object'));
289
        $this->assertEquals('["airbus"]', $field->query('#>', '{"planes":"french"}'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
290
291
        // Data Source: Object
292
        // Return Type: SILVERSTRIPE
293
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
294
        // Expect: Direct scalar comparison assertion (Varchar)
295
        $field->setReturnType('silverstripe');
296
        $field->setValue($this->getFixture('object'));
297
        $this->assertInternalType('array', $field->query('#>', '{"planes":"french"}'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
298
        $this->assertInstanceOf('Varchar', $field->query('#>', '{"planes":"french"}')[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
299
        $this->assertEquals('airbus', $field->query('#>', '{"planes":"french"}')[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
300
301
        // Data Source: Object
302
        // Return Type: SILVERSTRIPE
303
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
304
        // Expect: Direct scalar comparison assertion (Float)
305
        $field->setReturnType('silverstripe');
306
        $field->setValue($this->getFixture('object'));
307
        
308
        $res = $field->query('#>', '{"floats":"0"}');
309
        
310
        $this->assertInternalType('array', $res);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
311
        $this->assertInternalType('array', $res[0]); // Why? Because value of "floats" key is a JSON array
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
312
        $this->assertInstanceOf('Float', array_values($res[0])[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
313
        $this->assertEquals(99.99, array_values($res[0])[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
314
315
        // Data Source: Object
316
        // Return Type: SILVERSTRIPE
317
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
318
        // Expect: Direct scalar comparison assertion (Int)
319
        $field->setReturnType('silverstripe');
320
        $field->setValue($this->getFixture('object'));
321
322
        $res = $field->query('#>', '{"ints":"0"}');
323
324
        $this->assertInternalType('array', $res);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
325
        $this->assertInternalType('array', $res[0]); // Why? Because value of "floats" key is a JSON array
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
326
        $this->assertInstanceOf('Int', array_values($res[0])[1]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
327
        $this->assertEquals(6, array_values($res[0])[1]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
328
329
        // Data Source: Object
330
        // Return Type: SILVERSTRIPE
331
        // Operator: "#>" (Path)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
332
        // Expect: Direct scalar comparison assertion (Boolean)
333
        $field->setReturnType('silverstripe');
334
        $field->setValue($this->getFixture('object'));
335
336
        $res = $field->query('#>', '{"booleans":"0"}');
337
338
        $this->assertInternalType('array', $res);
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
339
        $this->assertInternalType('array', $res[0]); // Why? Because value of "booleans" key is a JSON array
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
340
        $this->assertInstanceOf('Boolean', array_values($res[0])[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
341
        $this->assertEquals(1, array_values($res[0])[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
342
343
        // #1 Empty source data
344
        $field->setReturnType('array');
345
        $field->setValue('');
346
        $this->assertEquals([], $field->query('#>', '{"japanese":"fast"}'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
347
348
        // #2 JSON path not found
349
        $field->setReturnType('silverstripe');
350
        $field->setValue($this->getFixture('object'));
351
        $this->assertNull($field->query('#>', '{"ints":"1"}')); // The "ints" key only has a single array as a value
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
352
353
        // #3 Invalid operand on RHS
354
        $this->setExpectedException('\JSONText\Exceptions\JSONTextException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
355
        $field->setReturnType('array');
356
        $field->setValue($this->getFixture('object'));
357
        $this->assertEquals(['Kawasaki' => 'KR1S250'], $field->query('#>', '{"japanese":"fast"'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
358
    }
359
360
    /**
361
     * Tests query() by means of JSONPath expressions.
362
     * N.b. only a minimum no. tests should be required, given that the 3rd party lib via which this functionality
363
     * is derived, is itself well tested.
364
     */
365
    public function testQueryWithMatchOnExpr()
366
    {
367
        $field = $this->sut;
368
        
369
        // Data Source: Object
370
        // Return Type: ARRAY
371
        // Expression: "$.." (Everything)
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
372
        // Expect: Array, obviously due to no. nodes in the source JSON
373
        $field->setReturnType('array');
374
        $field->setValue($this->getFixture('object'));
375
        $this->assertInternalType('array', $field->query('$..'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
376
        $this->assertCount(25, $field->query('$..'));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
377
378
        // Data Source: Object
379
        // Return Type: ARRAY
380
        // Expression: "$..japanese[*]" (An array of children of all keys matching "japanese")
381
        // Expect: Array
382
        $field->setReturnType('array');
383
        $field->setValue($this->getFixture('object'));
384
        $this->assertCount(4, $field->query('$..japanese[*]'));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
385
        $this->assertEquals([
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
386
            ['Subaru' => 'Impreza'],
387
            ['Honda' => 'Civic'],
388
            ['Kawasaki' => 'KR1S250'],
389
            ['Honda' => 'FS1']
390
        ], $field->query('$..japanese[*]'));
391
392
        // Data Source: Object
393
        // Return Type: JSON
394
        // Expression: "$..japanese[*]" (An array of children of all keys matching "japanese")
395
        // Expect: JSON Array of JSON objects
396
        $field->setReturnType('json');
397
        $field->setValue($this->getFixture('object'));
398
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
399
            '[{"Subaru":"Impreza"},{"Honda":"Civic"},{"Kawasaki":"KR1S250"},{"Honda":"FS1"}]',
400
            $field->query('$..japanese[*]')
401
        );
402
403
        // Data Source: Object
404
        // Return Type: Array
405
        // Expression: "$.cars.american[*]" (All entries in the american cars node)
406
        // Expect: Array
407
        $field->setReturnType('array');
408
        $field->setValue($this->getFixture('object'));
409
        $this->assertEquals(['buick', 'oldsmobile'], $field->query('$.cars.american[*]'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
410
        $this->assertEquals(['buick'], $field->query('$.cars.american[0]'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
411
412
        // Data Source: Object
413
        // Return Type: Array
414
        // Expression: "$.cars.american[*]" (All entries in the american cars node)
415
        // Expect: Array 0f SilverStripe types
416
        $field->setReturnType('silverstripe');
417
        $field->setValue($this->getFixture('object'));
418
        $this->assertInternalType('array', $field->query('$.cars.american[*]'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
419
        $this->assertCount(2, $field->query('$.cars.american[*]'));
0 ignored issues
show
Bug introduced by
The method assertCount() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
420
        $this->assertInstanceOf('Varchar', $field->query('$.cars.american[*]')[0]);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
421
        $this->assertEquals('buick', $field->query('$.cars.american[*]')[0]->getValue());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
422
    }
423
424
    /**
425
     * Tests query() by means of passing bad argument combinations.
426
     */
427
    public function testQueryWithInvalidArgs()
428
    {
429
        $field = $this->sut;
430
431
        $this->setExpectedException('\JSONText\Exceptions\JSONTextException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
432
        $field->setValue('["trabant"]');
433
        $field->query('$.cars.american[*]', 'foo'); // Cannot pass multiple args when in JSONPath context
434
435
        $this->setExpectedException(null);
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<JSONTextQueryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
436
        $field->setValue('');
437
        $field->query('$.cars.american[*]', 'foo'); // Still shouldn't, but routine only kicks in _After_ checks made in setValue()
438
    }
439
    
440
    /**
441
     * Get the contents of a fixture
442
     * 
443
     * @param string $fixture
444
     * @return string
445
     */
446
    private function getFixture($fixture)
447
    {
448
        $files = $this->fixtures;
449
        return file_get_contents($files[$fixture]);
450
    }
451
452
}
453