Completed
Push — master ( f2c532...9eb09d )
by Russell
02:59
created

JSONTextQueryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
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;
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\Fields\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
        // Test: Invalid #2
129
        $field->setReturnType('array');
130
        $field->setValue('["ass"]');
131
        $this->assertEquals(['ass'], $field->query('->', 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...
132
133
        // Test: Invalid #3
134
        $field->setReturnType('array');
135
        $field->setValue('{');
136
        $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...
137
        $field->query('->', 3);
138
    }
139
140
    /**
141
     * Tests query() by means of the integer Postgres String match operator: '->>'
142
     */
143
    public function testQueryWithMatchOnStr()
144
    {
145
        $field = $this->sut;
146
        
147
        // Data Source: Object
148
        // Return Type: ARRAY
149
        // Operator: "->>" (String)
150
        $field->setReturnType('array');
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: JSON
160
        // Operator: "->>" (String)
161
        $field->setReturnType('json');
162
        $field->setValue($this->getFixture('object'));
163
        $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...
164
        $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...
165
            '{"japanese":{"fast":{"Subaru":"Impreza"},"slow":{"Honda":"Civic"}}}',
166
            $field->query('->>', 'japanese')
167
        );
168
169
        // Data Source: Object
170
        // Return Type: SilverStripe
171
        // Operator: "->>" (String)
172
        // SS Type: Varchar
173
        $field->setReturnType('silverstripe');
174
        $field->setValue($this->getFixture('object'));
175
        $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...
176
        $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...
177
        $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...
178
179
        // Data Source: Object
180
        // Return Type: SilverStripe
181
        // Operator: "->>" (String)
182
        // SS Type: Boolean
183
        $field->setReturnType('silverstripe');
184
        $field->setValue($this->getFixture('object'));
185
        $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...
186
        $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...
187
        $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...
188
189
        // Data Source: Object
190
        // Return Type: SilverStripe
191
        // Operator: "->>" (String)
192
        // SS Type: Float
193
        $field->setReturnType('silverstripe');
194
        $field->setValue($this->getFixture('object'));
195
        $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...
196
        $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...
197
        $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...
198
199
        // Data Source: Object
200
        // Return Type: SilverStripe
201
        // Operator: "->>" (String)
202
        // SS Type: Int
203
        $field->setReturnType('silverstripe');
204
        $field->setValue($this->getFixture('object'));
205
        $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...
206
        $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...
207
        $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...
208
209
        // Data Source: Object
210
        // Return Type: SilverStripe
211
        // Operator: "->>" (String)
212
        // SS Type: N/A Nested sub-array example, expect an array
213
        $field->setReturnType('silverstripe');
214
        $field->setValue($this->getFixture('object'));
215
        $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...
216
        $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...
217
        $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...
218
        $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...
219
        $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...
220
221
        // Test: Empty #1
222
        $field->setReturnType('array');
223
        $field->setValue('');
224
        $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...
225
        $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...
226
227
        // Test: Empty #2
228
        $field->setReturnType('array');
229
        $field->setValue('["morris"]');
230
        $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...
231
232
        // Test: Invalid #1
233
        $field->setReturnType('array');
234
        $field->setValue('["trabant"]');
235
        $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...
236
237
        // Test: Invalid #2
238
        $field->setReturnType('array');
239
        $field->setValue('{');
240
        $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...
241
        $field->query('->', 3);
242
    }
243
244
    /**
245
     * Tests query() by means of the Postgres path-match operator: '#>'
246
     */
247
    public function testQueryWithMatchOnPath()
248
    {
249
        $field = $this->sut;
250
        
251
        // Data Source: Object
252
        // Return Type: ARRAY
253
        // 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...
254
        // Expect: Array due to duplicate keys in different parts of the source data
255
        $field->setReturnType('array');
256
        $field->setValue($this->getFixture('object'));
257
        $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...
258
            [['Subaru' => 'Impreza'],['Kawasaki' => 'KR1S250']],
259
            $field->query('#>', '{"japanese":"fast"}')
260
        );
261
262
        // Data Source: Object
263
        // Return Type: JSON
264
        // 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...
265
        // Expect: Array due to duplicate keys in different parts of the source data
266
        $field->setReturnType('json');
267
        $field->setValue($this->getFixture('object'));
268
        $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...
269
            '[{"Subaru":"Impreza"},{"Kawasaki":"KR1S250"}]',
270
            $field->query('#>', '{"japanese":"fast"}')
271
        );
272
273
        // Data Source: Object
274
        // Return Type: SILVERSTRIPE
275
        // 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...
276
        // Expect: Array due to duplicate keys in different parts of the source data
277
        $field->setReturnType('silverstripe');
278
        $field->setValue($this->getFixture('object'));
279
        $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...
280
        $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...
281
        
282
        $one = $field->query('#>', '{"japanese":"fast"}')[0];
283
        $two = $field->query('#>', '{"japanese":"fast"}')[1];
284
        
285
        $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...
286
        $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...
287
        $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...
288
        $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...
289
        $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...
290
        $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...
291
292
        // Data Source: Object
293
        // Return Type: ARRAY
294
        // 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...
295
        // Expect: Direct scalar comparison assertion
296
        $field->setReturnType('array');
297
        $field->setValue($this->getFixture('object'));
298
        $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...
299
300
        // Data Source: Object
301
        // Return Type: JSON
302
        // 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...
303
        // Expect: Direct scalar comparison assertion
304
        $field->setReturnType('json');
305
        $field->setValue($this->getFixture('object'));
306
        $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...
307
308
        // Data Source: Object
309
        // Return Type: SILVERSTRIPE
310
        // 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...
311
        // Expect: Direct scalar comparison assertion (Varchar)
312
        $field->setReturnType('silverstripe');
313
        $field->setValue($this->getFixture('object'));
314
        $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...
315
        $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...
316
        $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...
317
318
        // Data Source: Object
319
        // Return Type: SILVERSTRIPE
320
        // 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...
321
        // Expect: Direct scalar comparison assertion (Float)
322
        $field->setReturnType('silverstripe');
323
        $field->setValue($this->getFixture('object'));
324
        
325
        $res = $field->query('#>', '{"floats":"0"}');
326
        
327
        $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...
328
        $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...
329
        $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...
330
        $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...
331
332
        // Data Source: Object
333
        // Return Type: SILVERSTRIPE
334
        // 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...
335
        // Expect: Direct scalar comparison assertion (Int)
336
        $field->setReturnType('silverstripe');
337
        $field->setValue($this->getFixture('object'));
338
339
        $res = $field->query('#>', '{"ints":"0"}');
340
341
        $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...
342
        $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...
343
        $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...
344
        $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...
345
346
        // Data Source: Object
347
        // Return Type: SILVERSTRIPE
348
        // 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...
349
        // Expect: Direct scalar comparison assertion (Boolean)
350
        $field->setReturnType('silverstripe');
351
        $field->setValue($this->getFixture('object'));
352
353
        $res = $field->query('#>', '{"booleans":"0"}');
354
355
        $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...
356
        $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...
357
        $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...
358
        $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...
359
360
        // #1 Empty source data
361
        $field->setReturnType('array');
362
        $field->setValue('');
363
        $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...
364
365
        // #2 JSON path not found
366
        $field->setReturnType('silverstripe');
367
        $field->setValue($this->getFixture('object'));
368
        $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...
369
370
        // #3 Invalid operand on RHS
371
        $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...
372
        $field->setReturnType('array');
373
        $field->setValue($this->getFixture('object'));
374
        $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...
375
    }
376
377
    /**
378
     * Tests query() by means of JSONPath expressions.
379
     * N.b. only a minimum no. tests should be required, given that the 3rd party lib via which this functionality
380
     * is derived, is itself well tested.
381
     */
382
    public function testQueryWithMatchOnExpr()
383
    {
384
        $field = $this->sut;
385
        
386
        // Data Source: Object
387
        // Return Type: ARRAY
388
        // 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...
389
        // Expect: Array, obviously due to no. nodes in the source JSON
390
        $field->setReturnType('array');
391
        $field->setValue($this->getFixture('object'));
392
        $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...
393
        $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...
394
395
        // Data Source: Object
396
        // Return Type: ARRAY
397
        // Expression: "$..japanese[*]" (An array of children of all keys matching "japanese")
398
        // Expect: Array
399
        $field->setReturnType('array');
400
        $field->setValue($this->getFixture('object'));
401
        $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...
402
        $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...
403
            ['Subaru' => 'Impreza'],
404
            ['Honda' => 'Civic'],
405
            ['Kawasaki' => 'KR1S250'],
406
            ['Honda' => 'FS1']
407
        ], $field->query('$..japanese[*]'));
408
409
        // Data Source: Object
410
        // Return Type: JSON
411
        // Expression: "$..japanese[*]" (An array of children of all keys matching "japanese")
412
        // Expect: JSON Array of JSON objects
413
        $field->setReturnType('json');
414
        $field->setValue($this->getFixture('object'));
415
        $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...
416
            '[{"Subaru":"Impreza"},{"Honda":"Civic"},{"Kawasaki":"KR1S250"},{"Honda":"FS1"}]',
417
            $field->query('$..japanese[*]')
418
        );
419
420
        // Data Source: Object
421
        // Return Type: Array
422
        // Expression: "$.cars.american[*]" (All entries in the american cars node)
423
        // Expect: Array
424
        $field->setReturnType('array');
425
        $field->setValue($this->getFixture('object'));
426
        $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...
427
        $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...
428
429
        // Data Source: Object
430
        // Return Type: Array
431
        // Expression: "$.cars.american[*]" (All entries in the american cars node)
432
        // Expect: Array 0f SilverStripe types
433
        $field->setReturnType('silverstripe');
434
        $field->setValue($this->getFixture('object'));
435
        $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...
436
        $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...
437
        $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...
438
        $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...
439
    }
440
    
441
    /**
442
     * Get the contents of a fixture
443
     * 
444
     * @param string $fixture
445
     * @return string
446
     */
447
    private function getFixture($fixture)
448
    {
449
        $files = $this->fixtures;
450
        return file_get_contents($files[$fixture]);
451
    }
452
453
}
454