Completed
Push — master ( fcd719...7e2ade )
by Hung
01:26
created

SphinxQLTest   B

Complexity

Total Complexity 34

Size/Duplication

Total Lines 1154
Duplicated Lines 0 %

Importance

Changes 18
Bugs 2 Features 2
Metric Value
c 18
b 2
f 2
dl 0
loc 1154
rs 8.5216
wmc 34

32 Methods

Rating   Name   Duplication   Size   Complexity  
A testTransactions() 0 6 1
A testEscapeMatch() 0 6 1
A testWhere() 0 75 1
A setUpBeforeClass() 0 7 1
B testWithinGroupOrderBy() 0 25 1
B testMatch() 0 93 1
A testEmptyQueue() 0 5 1
A testOrderBy() 0 21 1
A testReplace() 0 63 1
B testUpdate() 0 79 1
A testExpr() 0 11 1
A testOffset() 0 12 1
B testInsert() 0 110 1
A testHalfEscapeMatch() 0 8 1
A testHaving() 0 22 1
A testQueue() 0 19 1
A refill() 0 14 2
A testLimit() 0 21 1
A testGroupBy() 0 13 1
A testOption() 0 54 1
A createSphinxQL() 0 3 1
B testGroupNBy() 0 34 1
B testQuery() 0 34 1
A testDelete() 0 12 1
A testEscapeChars() 0 11 1
A testGetSelect() 0 6 1
A testClosureMisuse() 0 18 1
B testFacet() 0 40 2
B testSetSelect() 0 34 1
B testResetMethods() 0 27 1
B testSelect() 0 40 1
A testSubselect() 0 50 1
1
<?php
2
3
use Foolz\SphinxQL\Expression;
4
use Foolz\SphinxQL\Facet;
5
use Foolz\SphinxQL\Helper;
6
use Foolz\SphinxQL\Match;
7
use Foolz\SphinxQL\SphinxQL;
8
use Foolz\SphinxQL\Tests\TestUtil;
9
10
class SphinxQLTest extends \PHPUnit\Framework\TestCase
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...
11
{
12
    public static $conn = null;
13
14
    public static $data = array (
15
        0 => array('id' => '10', 'gid' => '9003',
16
            'title' => 'modifying the same line again', 'content' => 'because i am that lazy'),
17
        1 => array('id' => '11', 'gid' => '201',
18
            'title' => 'replacing value by value', 'content' => 'i have no idea who would use this directly'),
19
        2 => array('id' => '12', 'gid' => '200',
20
            'title' => 'simple logic', 'content' => 'inside the box there was the content'),
21
        3 => array('id' => '13', 'gid' => '304',
22
            'title' => 'i am getting bored', 'content' => 'with all this CONTENT'),
23
        4 => array('id' => '14', 'gid' => '304',
24
            'title' => 'i want a vacation', 'content' => 'the code is going to break sometime'),
25
        5 => array('id' => '15', 'gid' => '304',
26
            'title' => 'there\'s no hope in this class', 'content' => 'just give up'),
27
        6 => array('id' => '16', 'gid' => '500',
28
            'title' => 'we need to test', 'content' => 'selecting the best result in groups'),
29
        7 => array('id' => '17', 'gid' => '500',
30
            'title' => 'what is there to do', 'content' => 'we need to create dummy data for tests'),
31
    );
32
33
    public static function setUpBeforeClass()
34
    {
35
        $conn = TestUtil::getConnectionDriver();
36
        $conn->setParam('port', 9307);
37
        self::$conn = $conn;
38
39
        (new SphinxQL(self::$conn))->getConnection()->query('TRUNCATE RTINDEX rt');
40
    }
41
42
    /**
43
     * @return SphinxQL
44
     */
45
    protected function createSphinxQL()
46
    {
47
        return new SphinxQL(self::$conn);
48
    }
49
50
    public function refill()
51
    {
52
        $this->createSphinxQL()->getConnection()->query('TRUNCATE RTINDEX rt');
53
54
        $sq = $this->createSphinxQL()
55
            ->insert()
56
            ->into('rt')
57
            ->columns('id', 'gid', 'title', 'content');
58
59
        foreach (static::$data as $row) {
60
            $sq->values($row['id'], $row['gid'], $row['title'], $row['content']);
61
        }
62
63
        $sq->execute();
64
    }
65
66
    public function testExpr()
67
    {
68
        $result = SphinxQL::expr('');
69
70
        $this->assertInstanceOf(Expression::class, $result);
71
        $this->assertEquals('', (string) $result);
72
73
        $result = SphinxQL::expr('* \\ Ç"" \'');
74
75
        $this->assertInstanceOf(Expression::class, $result);
76
        $this->assertEquals('* \\ Ç"" \'', (string) $result);
77
    }
78
79
    /**
80
     * @covers \Foolz\SphinxQL\SphinxQL::transactionBegin
81
     * @covers \Foolz\SphinxQL\SphinxQL::transactionCommit
82
     * @covers \Foolz\SphinxQL\SphinxQL::transactionRollback
83
     */
84
    public function testTransactions()
85
    {
86
        $this->createSphinxQL()->transactionBegin();
87
        $this->createSphinxQL()->transactionRollback();
88
        $this->createSphinxQL()->transactionBegin();
89
        $this->createSphinxQL()->transactionCommit();
90
    }
91
92
    public function testQuery()
93
    {
94
        $describe = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

94
        $describe = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
95
            ->query('DESCRIBE rt')
96
            ->execute()
97
            ->getStored();
98
99
        array_shift($describe);
0 ignored issues
show
Bug introduced by
It seems like $describe can also be of type integer; however, parameter $array of array_shift() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
        array_shift(/** @scrutinizer ignore-type */ $describe);
Loading history...
100
        $this->assertSame(
101
            array(
102
                //	array('Field' => 'id', 'Type' => 'integer'), this can be bigint on id64 sphinx
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% 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...
103
                array('Field' => 'title', 'Type' => 'field'),
104
                array('Field' => 'content', 'Type' => 'field'),
105
                array('Field' => 'gid', 'Type' => 'uint'),
106
            ),
107
            $describe
108
        );
109
110
        $describe = $this->createSphinxQL()
111
            ->query('DESCRIBE rt');
112
        $describe->execute();
113
        $describe = $describe
114
            ->getResult()
115
            ->getStored();
116
117
        array_shift($describe);
118
        $this->assertSame(
119
            array(
120
                //	array('Field' => 'id', 'Type' => 'integer'), this can be bigint on id64 sphinx
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% 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...
121
                array('Field' => 'title', 'Type' => 'field'),
122
                array('Field' => 'content', 'Type' => 'field'),
123
                array('Field' => 'gid', 'Type' => 'uint'),
124
            ),
125
            $describe
126
        );
127
    }
128
129
    /**
130
     * @covers \Foolz\SphinxQL\SphinxQL::compile
131
     * @covers \Foolz\SphinxQL\SphinxQL::compileInsert
132
     * @covers \Foolz\SphinxQL\SphinxQL::compileSelect
133
     * @covers \Foolz\SphinxQL\SphinxQL::insert
134
     * @covers \Foolz\SphinxQL\SphinxQL::set
135
     * @covers \Foolz\SphinxQL\SphinxQL::value
136
     * @covers \Foolz\SphinxQL\SphinxQL::columns
137
     * @covers \Foolz\SphinxQL\SphinxQL::values
138
     * @covers \Foolz\SphinxQL\SphinxQL::into
139
     */
140
    public function testInsert()
141
    {
142
        $this->createSphinxQL()
143
            ->insert()
144
            ->into('rt')
145
            ->set(array(
146
                'id' => 10,
147
                'title' => 'the story of a long test unit',
148
                'content' => 'once upon a time there was a foo in the bar',
149
                'gid' => 9001
150
            ))
151
            ->execute();
152
153
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

153
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
154
            ->select()
155
            ->from('rt')
156
            ->execute()
157
            ->getStored();
158
159
        $this->assertCount(1, $result);
160
161
        $this->createSphinxQL()
162
            ->insert()
163
            ->into('rt')
164
            ->columns('id', 'title', 'content', 'gid')
165
            ->values(11, 'this is a title', 'this is the content', 100)
166
            ->execute();
167
168
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

168
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
169
            ->select()
170
            ->from('rt')
171
            ->execute()
172
            ->getStored();
173
174
        $this->assertCount(2, $result);
175
176
        $this->createSphinxQL()
177
            ->insert()
178
            ->into('rt')
179
            ->value('id', 12)
180
            ->value('title', 'simple logic')
181
            ->value('content', 'inside the box there was the content')
182
            ->value('gid', 200)
183
            ->execute();
184
185
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

185
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
186
            ->select()
187
            ->from('rt')
188
            ->execute()
189
            ->getStored();
190
191
        $this->assertCount(3, $result);
192
193
        $this->createSphinxQL()
194
            ->insert()
195
            ->into('rt')
196
            ->columns(array('id', 'title', 'content', 'gid'))
197
            ->values(array(13, 'i am getting bored', 'with all this CONTENT', 300))
198
            ->values(14, 'i want a vacation', 'the code is going to break sometime', 300)
199
            ->values(15, 'there\'s no hope in this class', 'just give up', 300)
200
            ->execute();
201
202
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

202
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
203
            ->select()
204
            ->from('rt')
205
            ->execute()
206
            ->getStored();
207
208
        $this->assertCount(6, $result);
209
210
        $this->createSphinxQL()
211
            ->insert()
212
            ->into('rt')
213
            ->columns('id', 'title', 'content', 'gid')
214
            ->values(16, 'we need to test', 'selecting the best result in groups', 500)
215
            ->values(17, 'what is there to do', 'we need to create dummy data for tests', 500)
216
            ->execute();
217
218
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

218
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
219
            ->select()
220
            ->from('rt')
221
            ->execute()
222
            ->getStored();
223
224
        $this->assertCount(8, $result);
225
226
        $this->createSphinxQL()
227
            ->insert()
228
            ->into('rt')
229
            ->set(array(
230
                'id' => 18,
231
                'title' => 'a multi set test',
232
                'content' => 'has text',
233
                'gid' => 9002
234
            ))
235
            ->set(array(
236
                'id' => 19,
237
                'title' => 'and a',
238
                'content' => 'second set call',
239
                'gid' => 9003
240
            ))
241
            ->execute();
242
243
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

243
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
244
            ->select()
245
            ->from('rt')
246
            ->execute()
247
            ->getStored();
248
249
        $this->assertCount(10, $result);
250
251
    }
252
253
    /**
254
     * @covers \Foolz\SphinxQL\SphinxQL::compile
255
     * @covers \Foolz\SphinxQL\SphinxQL::compileInsert
256
     * @covers \Foolz\SphinxQL\SphinxQL::compileSelect
257
     * @covers \Foolz\SphinxQL\SphinxQL::replace
258
     * @covers \Foolz\SphinxQL\SphinxQL::set
259
     * @covers \Foolz\SphinxQL\SphinxQL::value
260
     * @covers \Foolz\SphinxQL\SphinxQL::columns
261
     * @covers \Foolz\SphinxQL\SphinxQL::values
262
     * @covers \Foolz\SphinxQL\SphinxQL::into
263
     */
264
    public function testReplace()
265
    {
266
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

266
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
267
            ->replace()
268
            ->into('rt')
269
            ->set(array(
270
                'id' => 10,
271
                'title' => 'modified',
272
                'content' => 'this field was modified with replace',
273
                'gid' => 9002
274
            ))
275
            ->execute()
276
            ->getStored();
277
278
        $this->assertSame(1, $result);
279
280
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

280
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
281
            ->select()
282
            ->from('rt')
283
            ->where('id', '=', 10)
284
            ->execute()
285
            ->getStored();
286
287
        $this->assertEquals('9002', $result[0]['gid']);
288
289
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

289
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
290
            ->replace()
291
            ->into('rt')
292
            ->columns('id', 'title', 'content', 'gid')
293
            ->values(10, 'modifying the same line again', 'because i am that lazy', 9003)
294
            ->values(11, 'i am getting really creative with these strings', 'i\'ll need them to test MATCH!', 300)
295
            ->execute()
296
            ->getStored();
297
298
        $this->assertSame(2, $result);
299
300
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

300
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
301
            ->select()
302
            ->from('rt')
303
            ->where('id', 'IN', array(10, 11))
304
            ->execute()
305
            ->getStored();
306
307
        $this->assertEquals('9003', $result[0]['gid']);
308
        $this->assertEquals('300', $result[1]['gid']);
309
310
        $this->createSphinxQL()
311
            ->replace()
312
            ->into('rt')
313
            ->value('id', 11)
314
            ->value('title', 'replacing value by value')
315
            ->value('content', 'i have no idea who would use this directly')
316
            ->value('gid', 200)
317
            ->execute();
318
319
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

319
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
320
            ->select()
321
            ->from('rt')
322
            ->where('id', '=', 11)
323
            ->execute()
324
            ->getStored();
325
326
        $this->assertEquals('200', $result[0]['gid']);
327
    }
328
329
    /**
330
     * @covers \Foolz\SphinxQL\SphinxQL::compile
331
     * @covers \Foolz\SphinxQL\SphinxQL::compileUpdate
332
     * @covers \Foolz\SphinxQL\SphinxQL::compileSelect
333
     * @covers \Foolz\SphinxQL\SphinxQL::update
334
     * @covers \Foolz\SphinxQL\SphinxQL::value
335
     */
336
    public function testUpdate()
337
    {
338
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

338
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
339
            ->update('rt')
340
            ->where('id', '=', 11)
341
            ->value('gid', 201)
342
            ->execute()
343
            ->getStored();
344
345
        $this->assertSame(1, $result);
346
347
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

347
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
348
            ->update('rt')
349
            ->where('gid', '=', 300)
350
            ->value('gid', 305)
351
            ->execute()
352
            ->getStored();
353
354
        $this->assertSame(3, $result);
355
356
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

356
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
357
            ->select()
358
            ->from('rt')
359
            ->where('id', '=', 11)
360
            ->execute()
361
            ->getStored();
362
363
        $this->assertEquals('201', $result[0]['gid']);
364
365
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

365
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
366
            ->update('rt')
367
            ->where('gid', '=', 305)
368
            ->set(array('gid' => 304))
369
            ->execute()
370
            ->getStored();
371
372
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

372
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
373
            ->select()
374
            ->from('rt')
375
            ->where('gid', '=', 304)
376
            ->execute()
377
            ->getStored();
378
379
        $this->assertCount(3, $result);
380
381
        self::$conn->query('ALTER TABLE rt ADD COLUMN tags MULTI');
382
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

382
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
383
            ->select()
384
            ->from('rt')
385
            ->where('tags', 222)
386
            ->execute()
387
            ->getStored();
388
        $this->assertEmpty($result);
389
390
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

390
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
391
            ->update('rt')
392
            ->where('id', '=', 15)
393
            ->value('tags', array(111, 222))
0 ignored issues
show
Bug introduced by
array(111, 222) of type array<integer,integer> is incompatible with the type string expected by parameter $value of Foolz\SphinxQL\SphinxQL::value(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

393
            ->value('tags', /** @scrutinizer ignore-type */ array(111, 222))
Loading history...
394
            ->execute()
395
            ->getStored();
396
        $this->assertSame(1, $result);
397
398
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

398
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
399
            ->select()
400
            ->from('rt')
401
            ->where('tags', 222)
402
            ->execute()
403
            ->getStored();
404
        $this->assertEquals(
405
            array(
406
                array(
407
                    'id'   => '15',
408
                    'gid'  => '304',
409
                    'tags' => '111,222',
410
                ),
411
            ),
412
            $result
413
        );
414
        self::$conn->query('ALTER TABLE rt DROP COLUMN tags');
415
    }
416
417
    /**
418
     * @covers \Foolz\SphinxQL\SphinxQL::compileWhere
419
     * @covers \Foolz\SphinxQL\SphinxQL::from
420
     * @covers \Foolz\SphinxQL\SphinxQL::compileFilterCondition
421
     */
422
    public function testWhere()
423
    {
424
        $this->refill();
425
426
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

426
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
427
            ->select()
428
            ->from('rt')
429
            ->where('gid', 'BETWEEN', array(300, 400))
430
            ->execute()
431
            ->getStored();
432
433
        $this->assertCount(3, $result);
434
435
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

435
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
436
            ->select()
437
            ->from('rt')
438
            ->where('id', 'IN', array(11, 12, 13))
439
            ->execute()
440
            ->getStored();
441
442
        $this->assertCount(3, $result);
443
444
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

444
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
445
            ->select()
446
            ->from('rt')
447
            ->where('id', 'NOT IN', array(11, 12))
448
            ->execute()
449
            ->getStored();
450
451
        $this->assertCount(6, $result);
452
453
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

453
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
454
            ->select()
455
            ->from('rt')
456
            ->where('gid', '>', 300)
457
            ->execute()
458
            ->getStored();
459
460
        $this->assertCount(6, $result);
461
462
        $result = $this->createSphinxQL()
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

462
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
463
            ->select()
464
            ->from('rt')
465
            ->where('gid', 304)
466
            ->execute()
467
            ->getStored();
468
469
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

469
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
470
            ->select()
471
            ->from('rt')
472
            ->where('gid', '>', 300)
473
            ->execute()
474
            ->getStored();
475
476
        $this->assertCount(6, $result);
477
478
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

478
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
479
            ->select()
480
            ->from('rt')
481
            ->where('gid', '>', 300)
482
            ->where('id', '!=', 15)
483
            ->execute()
484
            ->getStored();
485
486
        $this->assertCount(5, $result);
487
488
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

488
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
489
            ->select()
490
            ->from('rt')
491
            ->match('content', 'content')
492
            ->where('gid', '>', 200)
493
            ->execute()
494
            ->getStored();
495
496
        $this->assertCount(1, $result);
497
    }
498
499
    /**
500
     * @covers \Foolz\SphinxQL\SphinxQL::match
501
     * @covers \Foolz\SphinxQL\SphinxQL::compileMatch
502
     * @covers \Foolz\SphinxQL\SphinxQL::halfEscapeMatch
503
     */
504
    public function testMatch()
505
    {
506
        $this->refill();
507
508
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

508
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
509
            ->select()
510
            ->from('rt')
511
            ->match('content', 'content')
512
            ->execute()
513
            ->getStored();
514
515
        $this->assertCount(2, $result);
516
517
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

517
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
518
            ->select()
519
            ->from('rt')
520
            ->match('title', 'value')
521
            ->execute()
522
            ->getStored();
523
524
        $this->assertCount(1, $result);
525
526
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

526
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
527
            ->select()
528
            ->from('rt')
529
            ->match('title', 'value')
530
            ->match('content', 'directly')
531
            ->execute()
532
            ->getStored();
533
534
        $this->assertCount(1, $result);
535
536
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

536
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
537
            ->select()
538
            ->from('rt')
539
            ->match('*', 'directly')
540
            ->execute()
541
            ->getStored();
542
543
        $this->assertCount(1, $result);
544
545
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

545
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
546
            ->select()
547
            ->from('rt')
548
            ->match(array('title', 'content'), 'to')
549
            ->execute()
550
            ->getStored();
551
552
        $this->assertCount(3, $result);
553
554
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

554
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
555
            ->select()
556
            ->from('rt')
557
            ->match('content', 'directly | lazy', true)
558
            ->execute()
559
            ->getStored();
560
561
        $this->assertCount(2, $result);
562
563
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

563
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
564
            ->select()
565
            ->from('rt')
566
            ->match(function ($m) {
567
                $m->field('content')
568
                    ->match('directly')
569
                    ->orMatch('lazy');
570
            })
571
            ->execute()
572
            ->getStored();
573
574
        $this->assertCount(2, $result);
575
576
        $match = (new Match($this->createSphinxQL()))
577
            ->field('content')
578
            ->match('directly')
579
            ->orMatch('lazy');
580
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

580
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
581
            ->select()
582
            ->from('rt')
583
            ->match($match)
584
            ->execute()
585
            ->getStored();
586
587
        $this->assertCount(2, $result);
588
589
        $result = $this->createSphinxQL()
590
            ->select()
591
            ->from('rt')
592
            ->match('')
593
            ->compile()
594
            ->getCompiled();
595
596
        $this->assertEquals('SELECT * FROM rt WHERE MATCH(\'\')', $result);
597
    }
598
599
    public function testEscapeMatch()
600
    {
601
        $match = 'this MAYBE that^32 and | hi';
602
        $this->assertSame('this maybe that\^32 and \| hi', $this->createSphinxQL()->escapeMatch($match));
603
        $this->assertSame($match, $this->createSphinxQL()->escapeMatch(SphinxQL::expr($match)));
604
        $this->assertSame('stärkergradig \| mb', $this->createSphinxQL()->escapeMatch('stärkergradig | mb'));
605
    }
606
607
    public function testHalfEscapeMatch()
608
    {
609
        $match = 'this MAYBE that^32 and | hi';
610
        $this->assertSame('this maybe that\^32 and | hi', $this->createSphinxQL()->halfEscapeMatch($match));
611
        $this->assertSame($match, $this->createSphinxQL()->halfEscapeMatch(SphinxQL::expr($match)));
612
        $this->assertSame('this \- not -that | hi \-', $this->createSphinxQL()->halfEscapeMatch('this -- not -that | | hi -'));
613
        $this->assertSame('stärkergradig | mb', $this->createSphinxQL()->halfEscapeMatch('stärkergradig | mb'));
614
        $this->assertSame('"unmatched quotes"', $this->createSphinxQL()->halfEscapeMatch('"unmatched quotes'));
615
    }
616
617
    /**
618
    * @covers \Foolz\SphinxQL\SphinxQL::setFullEscapeChars
619
    * @covers \Foolz\SphinxQL\SphinxQL::setHalfEscapeChars
620
    * @covers \Foolz\SphinxQL\SphinxQL::compileEscapeChars
621
    */
622
    public function testEscapeChars()
623
    {
624
        $this->assertEquals(array('%' => '\%'), $this->createSphinxQL()->compileEscapeChars(array('%')));
625
        $this->assertEquals(array('@' => '\@'), $this->createSphinxQL()->compileEscapeChars(array('@')));
626
627
        $match = 'this MAYBE that^32 and | hi';
628
        $sphinxql = $this->createSphinxQL()->setFullEscapeChars(array('^'));
629
        $this->assertSame('this maybe that\^32 and | hi', $sphinxql->escapeMatch($match));
630
631
        $sphinxql->setHalfEscapeChars(array('|'));
632
        $this->assertSame('this maybe that^32 and \| hi', $sphinxql->halfEscapeMatch($match));
633
    }
634
635
    public function testOption()
636
    {
637
        $this->refill();
638
639
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

639
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
640
            ->select()
641
            ->from('rt')
642
            ->match('content', 'content')
643
            ->option('max_matches', 1)
644
            ->execute()
645
            ->getStored();
646
647
        $this->assertCount(1, $result);
648
649
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

649
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
650
            ->select()
651
            ->from('rt')
652
            ->match('content', 'content')
653
            ->option('max_matches', SphinxQL::expr('1'))
654
            ->execute()
655
            ->getStored();
656
657
        $this->assertCount(1, $result);
658
659
        $result = $this->createSphinxQL()
660
            ->select()
661
            ->from('rt')
662
            ->option('comment', 'this should be quoted')
663
            ->compile()
664
            ->getCompiled();
665
666
        $this->assertEquals('SELECT * FROM rt OPTION comment = \'this should be quoted\'', $result);
667
668
        $result = $this->createSphinxQL()
669
            ->select()
670
            ->from('rt')
671
            ->option('field_weights', SphinxQL::expr('(content=50)'))
672
            ->compile()
673
            ->getCompiled();
674
675
        $this->assertEquals('SELECT * FROM rt OPTION field_weights = (content=50)', $result);
676
677
        $result = $this->createSphinxQL()
678
            ->select()
679
            ->from('rt')
680
            ->option('field_weights', array(
681
                'title'   => 80,
682
                'content' => 35,
683
                'tags'    => 92,
684
            ))
685
            ->compile()
686
            ->getCompiled();
687
688
        $this->assertEquals('SELECT * FROM rt OPTION field_weights = (title=80, content=35, tags=92)', $result);
689
    }
690
691
    public function testGroupBy()
692
    {
693
        $this->refill();
694
695
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

695
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
696
            ->select(SphinxQL::expr('count(*)'))
697
            ->from('rt')
698
            ->groupBy('gid')
699
            ->execute()
700
            ->getStored();
701
702
        $this->assertCount(5, $result);
703
        $this->assertEquals('3', $result[3]['count(*)']);
704
    }
705
706
    public function testHaving()
707
    {
708
        $this->refill();
709
710
        $result = $this->createSphinxQL()
711
            ->select(SphinxQL::expr('count(*) as cnt'))
712
            ->from('rt')
713
            ->groupBy('gid')
714
            ->having('cnt', '>', 1)
715
            ->execute();
716
717
        $this->assertCount(2, $result);
718
        $this->assertEquals('2', $result[1]['cnt']);
719
720
        $result = $this->createSphinxQL()
721
            ->select(SphinxQL::expr('count(*) as cnt'), SphinxQL::expr('GROUPBY() gd'))
722
            ->from('rt')
723
            ->groupBy('gid')
724
            ->having('gd', 304)
725
            ->execute();
726
727
        $this->assertCount(1, $result);
728
    }
729
730
    public function testOrderBy()
731
    {
732
        $this->refill();
733
734
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

734
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
735
            ->select()
736
            ->from('rt')
737
            ->orderBy('id', 'desc')
738
            ->execute()
739
            ->getStored();
740
741
        $this->assertEquals('17', $result[0]['id']);
742
743
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

743
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
744
            ->select()
745
            ->from('rt')
746
            ->orderBy('id', 'asc')
747
            ->execute()
748
            ->getStored();
749
750
        $this->assertEquals('10', $result[0]['id']);
751
    }
752
753
    public function testWithinGroupOrderBy()
754
    {
755
        $this->refill();
756
757
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

757
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
758
            ->select()
759
            ->from('rt')
760
            ->where('gid', 500)
761
            ->groupBy('gid')
762
            ->withinGroupOrderBy('id', 'desc')
763
            ->execute()
764
            ->getStored();
765
766
        $this->assertEquals('17', $result[0]['id']);
767
768
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

768
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
769
            ->select()
770
            ->from('rt')
771
            ->where('gid', 500)
772
            ->groupBy('gid')
773
            ->withinGroupOrderBy('id', 'asc')
774
            ->execute()
775
            ->getStored();
776
777
        $this->assertEquals('16', $result[0]['id']);
778
    }
779
780
    public function testGroupNBy()
781
    {
782
        $query = $this->createSphinxQL()
783
            ->select()
784
            ->from('rt')
785
            ->groupBy('gid');
786
        $this->assertEquals(
787
            'SELECT * FROM rt GROUP BY gid',
788
            $query->compile()->getCompiled()
789
        );
790
791
        $query->groupNBy(3);
792
        $this->assertEquals(
793
            'SELECT * FROM rt GROUP 3 BY gid',
794
            $query->compile()->getCompiled()
795
        );
796
797
        $query->resetGroupBy();
798
        $this->assertEquals(
799
            'SELECT * FROM rt',
800
            $query->compile()->getCompiled()
801
        );
802
803
        $query->groupBy('gid');
804
        $this->assertEquals(
805
            'SELECT * FROM rt GROUP BY gid',
806
            $query->compile()->getCompiled()
807
        );
808
809
        $query->resetGroupBy()
810
            ->groupNBy(3);
811
        $this->assertEquals(
812
            'SELECT * FROM rt',
813
            $query->compile()->getCompiled()
814
        );
815
    }
816
817
    public function testOffset()
818
    {
819
        $this->refill();
820
821
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

821
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
822
            ->select()
823
            ->from('rt')
824
            ->offset(4)
825
            ->execute()
826
            ->getStored();
827
828
        $this->assertCount(4, $result);
829
    }
830
831
    public function testLimit()
832
    {
833
        $this->refill();
834
835
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

835
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
836
            ->select()
837
            ->from('rt')
838
            ->limit(3)
839
            ->execute()
840
            ->getStored();
841
842
        $this->assertCount(3, $result);
843
844
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

844
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
845
            ->select()
846
            ->from('rt')
847
            ->limit(2, 3)
848
            ->execute()
849
            ->getStored();
850
851
        $this->assertCount(3, $result);
852
    }
853
854
    /**
855
     * @covers \Foolz\SphinxQL\SphinxQL::compile
856
     * @covers \Foolz\SphinxQL\SphinxQL::compileDelete
857
     * @covers \Foolz\SphinxQL\SphinxQL::delete
858
     */
859
    public function testDelete()
860
    {
861
        $this->refill();
862
863
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

863
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
864
            ->delete()
865
            ->from('rt')
866
            ->where('id', 'IN', array(10, 11, 12))
867
            ->execute()
868
            ->getStored();
869
870
        $this->assertSame(3, $result);
871
    }
872
873
    /**
874
     * @covers \Foolz\SphinxQL\SphinxQL::executeBatch
875
     * @covers \Foolz\SphinxQL\SphinxQL::enqueue
876
     * @covers \Foolz\SphinxQL\SphinxQL::getQueue
877
     * @covers \Foolz\SphinxQL\SphinxQL::getQueuePrev
878
     * @covers \Foolz\SphinxQL\SphinxQL::setQueuePrev
879
     */
880
    public function testQueue()
881
    {
882
        $this->refill();
883
884
        $result = $this->createSphinxQL()
885
            ->select()
886
            ->from('rt')
887
            ->where('gid', 9003)
888
            ->enqueue((new Helper(self::$conn))->showMeta())
889
            ->enqueue()
890
            ->select()
891
            ->from('rt')
892
            ->where('gid', 201)
893
            ->executeBatch()
894
            ->getStored();
895
896
        $this->assertEquals('10', $result[0][0]['id']);
897
        $this->assertEquals('1', $result[1][0]['Value']);
898
        $this->assertEquals('11', $result[2][0]['id']);
899
    }
900
901
    /**
902
     * @expectedException        Foolz\SphinxQL\Exception\SphinxQLException
903
     * @expectedExceptionMessage There is no Queue present to execute.
904
     */
905
    public function testEmptyQueue()
906
    {
907
        $this->createSphinxQL()
908
            ->executeBatch()
909
            ->getStored();
910
    }
911
912
    /**
913
     * @covers \Foolz\SphinxQL\SphinxQL::resetWhere
914
     * @covers \Foolz\SphinxQL\SphinxQL::resetMatch
915
     * @covers \Foolz\SphinxQL\SphinxQL::resetGroupBy
916
     * @covers \Foolz\SphinxQL\SphinxQL::resetWithinGroupOrderBy
917
     * @covers \Foolz\SphinxQL\SphinxQL::resetOptions
918
     * @covers \Foolz\SphinxQL\SphinxQL::resetFacets
919
     * @covers \Foolz\SphinxQL\SphinxQL::resetHaving
920
     * @covers \Foolz\SphinxQL\SphinxQL::resetOrderBy
921
     */
922
    public function testResetMethods()
923
    {
924
        $result = $this->createSphinxQL()
925
            ->select()
926
            ->from('rt')
927
            ->where('id', 'IN', array(10, 11))
928
            ->resetWhere()
929
            ->match('title', 'value')
930
            ->resetMatch()
931
            ->groupBy('gid')
932
            ->resetGroupBy()
933
            ->having('gid', '=', '304')
934
            ->resetHaving()
935
            ->withinGroupOrderBy('id', 'desc')
936
            ->resetWithinGroupOrderBy()
937
            ->option('comment', 'this should be quoted')
938
            ->resetOptions()
939
            ->orderBy('id', 'desc')
940
            ->resetOrderBy()
941
            ->facet(
942
                (new Facet(self::$conn))->facet(array('gid'))
943
            )
944
            ->resetFacets()
945
            ->compile()
946
            ->getCompiled();
947
948
        $this->assertEquals('SELECT * FROM rt', $result);
949
    }
950
951
    /**
952
     * @covers \Foolz\SphinxQL\SphinxQL::select
953
     */
954
    public function testSelect()
955
    {
956
        $this->refill();
957
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

957
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
958
            ->select(array('id', 'gid'))
959
            ->from('rt')
960
            ->execute()
961
            ->getStored();
962
        $this->assertArrayHasKey('id', $result[0]);
963
        $this->assertArrayHasKey('gid', $result[0]);
964
        $this->assertEquals('10', $result[0]['id']);
965
        $this->assertEquals('9003', $result[0]['gid']);
966
967
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

967
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
968
            ->select('id', 'gid')
969
            ->from('rt')
970
            ->execute()
971
            ->getStored();
972
        $this->assertArrayHasKey('id', $result[0]);
973
        $this->assertArrayHasKey('gid', $result[0]);
974
        $this->assertEquals('10', $result[0]['id']);
975
        $this->assertEquals('9003', $result[0]['gid']);
976
977
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

977
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
978
            ->select(array('id'))
979
            ->from('rt')
980
            ->execute()
981
            ->getStored();
982
        $this->assertArrayHasKey('id', $result[0]);
983
        $this->assertArrayNotHasKey('gid', $result[0]);
984
        $this->assertEquals('10', $result[0]['id']);
985
986
        $result = $this->createSphinxQL()
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

986
        $result = /** @scrutinizer ignore-deprecated */ $this->createSphinxQL()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
987
            ->select('id')
988
            ->from('rt')
989
            ->execute()
990
            ->getStored();
991
        $this->assertArrayHasKey('id', $result[0]);
992
        $this->assertArrayNotHasKey('gid', $result[0]);
993
        $this->assertEquals('10', $result[0]['id']);
994
    }
995
996
    public function testSubselect()
997
    {
998
        $this->refill();
999
        $query = $this->createSphinxQL()
1000
            ->select()
1001
            ->from(function ($q) {
1002
                $q->select('id')
1003
                    ->from('rt')
1004
                    ->orderBy('id', 'DESC');
1005
            })
1006
            ->orderBy('id', 'ASC');
1007
        $this->assertEquals(
1008
            'SELECT * FROM (SELECT id FROM rt ORDER BY id DESC) ORDER BY id ASC',
1009
            $query->compile()->getCompiled()
1010
        );
1011
        $result = $query
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1011
        $result = /** @scrutinizer ignore-deprecated */ $query

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1012
            ->execute()
1013
            ->getStored();
1014
        $this->assertArrayHasKey('id', $result[0]);
1015
        $this->assertArrayNotHasKey('gid', $result[0]);
1016
        $this->assertEquals('10', $result[0]['id']);
1017
1018
        $subquery = $this->createSphinxQL()
1019
            ->select('id')
1020
            ->from('rt')
1021
            ->orderBy('id', 'DESC');
1022
        $query = $this->createSphinxQL()
1023
            ->select()
1024
            ->from($subquery)
1025
            ->orderBy('id', 'ASC');
1026
        $this->assertEquals(
1027
            'SELECT id FROM rt ORDER BY id DESC',
1028
            $subquery->compile()->getCompiled()
1029
        );
1030
        $this->assertEquals(
1031
            'SELECT * FROM (SELECT id FROM rt ORDER BY id DESC) ORDER BY id ASC',
1032
            $query->compile()->getCompiled()
1033
        );
1034
        $result = $subquery
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1034
        $result = /** @scrutinizer ignore-deprecated */ $subquery

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1035
            ->execute()
1036
            ->getStored();
1037
        $this->assertArrayHasKey('id', $result[0]);
1038
        $this->assertArrayNotHasKey('gid', $result[0]);
1039
        $this->assertEquals('17', $result[0]['id']);
1040
        $result = $query
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1040
        $result = /** @scrutinizer ignore-deprecated */ $query

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1041
            ->execute()
1042
            ->getStored();
1043
        $this->assertArrayHasKey('id', $result[0]);
1044
        $this->assertArrayNotHasKey('gid', $result[0]);
1045
        $this->assertEquals('10', $result[0]['id']);
1046
    }
1047
1048
    /**
1049
     * @covers \Foolz\SphinxQL\SphinxQL::setSelect
1050
     */
1051
    public function testSetSelect()
1052
    {
1053
        $this->refill();
1054
        $q1 = $this->createSphinxQL()
1055
            ->select(array('id', 'gid'))
1056
            ->from('rt');
1057
        $q2 = clone $q1;
1058
        $q2->setSelect(array('id'));
1059
        $result = $q1
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1059
        $result = /** @scrutinizer ignore-deprecated */ $q1

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1060
            ->execute()
1061
            ->getStored();
1062
        $this->assertArrayHasKey('id', $result[0]);
1063
        $this->assertArrayHasKey('gid', $result[0]);
1064
        $result = $q2
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1064
        $result = /** @scrutinizer ignore-deprecated */ $q2

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1065
            ->execute()
1066
            ->getStored();
1067
        $this->assertArrayHasKey('id', $result[0]);
1068
        $this->assertArrayNotHasKey('gid', $result[0]);
1069
1070
        $q1 = $this->createSphinxQL()
1071
            ->select('id', 'gid')
1072
            ->from('rt');
1073
        $q2 = clone $q1;
1074
        $q2->setSelect('id');
1075
        $result = $q1
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1075
        $result = /** @scrutinizer ignore-deprecated */ $q1

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1076
            ->execute()
1077
            ->getStored();
1078
        $this->assertArrayHasKey('id', $result[0]);
1079
        $this->assertArrayHasKey('gid', $result[0]);
1080
        $result = $q2
0 ignored issues
show
Deprecated Code introduced by
The function Foolz\SphinxQL\Drivers\R...tInterface::getStored() has been deprecated: Commodity method for simple transition to version 1.0.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

1080
        $result = /** @scrutinizer ignore-deprecated */ $q2

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
1081
            ->execute()
1082
            ->getStored();
1083
        $this->assertArrayHasKey('id', $result[0]);
1084
        $this->assertArrayNotHasKey('gid', $result[0]);
1085
    }
1086
1087
    /**
1088
     * @covers \Foolz\SphinxQL\SphinxQL::getSelect
1089
     */
1090
    public function testGetSelect()
1091
    {
1092
        $query = $this->createSphinxQL()
1093
            ->select('id', 'gid')
1094
            ->from('rt');
1095
        $this->assertEquals(array('id', 'gid'), $query->getSelect());
1096
    }
1097
1098
    /**
1099
     * @covers \Foolz\SphinxQL\SphinxQL::facet
1100
     * @covers \Foolz\SphinxQL\SphinxQL::compileSelect
1101
     */
1102
    public function testFacet()
1103
    {
1104
        $this->refill();
1105
1106
        // test both setting and not setting the connection
1107
        foreach (array(self::$conn, null) as $conn) {
1108
            $result = $this->createSphinxQL()
1109
                ->select()
1110
                ->from('rt')
1111
                ->facet((new Facet($conn))
1112
                    ->facetFunction('INTERVAL', array('gid', 300, 600))
1113
                    ->orderByFunction('FACET', '', 'ASC'))
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type array expected by parameter $params of Foolz\SphinxQL\Facet::orderByFunction(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1113
                    ->orderByFunction('FACET', /** @scrutinizer ignore-type */ '', 'ASC'))
Loading history...
1114
                ->executeBatch()
1115
                ->getStored();
1116
1117
            $this->assertArrayHasKey('id', $result[0][0]);
1118
            $this->assertArrayHasKey('interval(gid,300,600)', $result[1][0]);
1119
            $this->assertArrayHasKey('count(*)', $result[1][0]);
1120
1121
            $this->assertEquals('2', $result[1][0]['count(*)']);
1122
            $this->assertEquals('5', $result[1][1]['count(*)']);
1123
            $this->assertEquals('1', $result[1][2]['count(*)']);
1124
1125
            $result = $this->createSphinxQL()
1126
                ->select()
1127
                ->from('rt')
1128
                ->facet((new Facet($conn))
1129
                    ->facet(array('gid'))
1130
                    ->orderBy('gid', 'ASC'))
1131
                ->executeBatch()
1132
                ->getStored();
1133
1134
            $this->assertArrayHasKey('id', $result[0][0]);
1135
            $this->assertArrayHasKey('gid', $result[1][0]);
1136
            $this->assertArrayHasKey('count(*)', $result[1][0]);
1137
1138
            $this->assertEquals('1', $result[1][0]['count(*)']);
1139
            $this->assertEquals('200', $result[1][0]['gid']);
1140
            $this->assertEquals('3', $result[1][2]['count(*)']);
1141
            $this->assertEquals('2', $result[1][3]['count(*)']);
1142
        }
1143
    }
1144
1145
    // issue #82
1146
    public function testClosureMisuse()
1147
    {
1148
        $query = $this->createSphinxQL()
1149
            ->select()
1150
            ->from('strlen')
1151
            ->orderBy('id', 'ASC');
1152
        $this->assertEquals(
1153
            'SELECT * FROM strlen ORDER BY id ASC',
1154
            $query->compile()->getCompiled()
1155
        );
1156
1157
        $query = $this->createSphinxQL()
1158
            ->select()
1159
            ->from('rt')
1160
            ->match('strlen', 'value');
1161
        $this->assertEquals(
1162
            "SELECT * FROM rt WHERE MATCH('(@strlen value)')",
1163
            $query->compile()->getCompiled()
1164
        );
1165
    }
1166
}
1167