Completed
Push — master ( 2afc86...6ca8f1 )
by Russell
02:59
created

JSONTextQueryTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 427
Duplicated Lines 0.7 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 2 Features 2
Metric Value
wmc 8
c 4
b 2
f 2
lcom 1
cbo 2
dl 3
loc 427
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 6 2
A setUp() 0 6 1
A testQueryWithMatchOnInt() 0 75 1
B testQueryWithMatchOnStr() 0 94 1
B testQueryWithMatchOnPath() 0 129 1
A testQueryWithMatchOnExpr() 0 58 1
A getFixture() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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