3
3
namespace React \Tests \Mysql \Io ;
4
4
5
5
use React \Mysql \Io \Connection ;
6
+ use React \Mysql \Io \Query ;
6
7
use React \Tests \Mysql \BaseTestCase ;
7
8
8
9
class ConnectionTest extends BaseTestCase
@@ -22,7 +23,7 @@ public function testIsBusyReturnsTrueWhenParserIsBusy()
22
23
23
24
$ connection = new Connection ($ stream , $ executor , $ parser , $ loop , null );
24
25
25
- $ connection ->query ('SELECT 1 ' );
26
+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
26
27
27
28
$ this ->assertTrue ($ connection ->isBusy ());
28
29
}
@@ -57,7 +58,7 @@ public function testQueryWillEnqueueOneCommand()
57
58
$ loop ->expects ($ this ->never ())->method ('addTimer ' );
58
59
59
60
$ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
60
- $ conn ->query ('SELECT 1 ' );
61
+ $ conn ->query (new Query ( 'SELECT 1 ' ) );
61
62
}
62
63
63
64
public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryCommandEmitsSuccess ()
@@ -81,7 +82,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryComm
81
82
82
83
$ this ->assertNull ($ currentCommand );
83
84
84
- $ promise = $ connection ->query ('SELECT 1 ' );
85
+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
85
86
86
87
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
87
88
@@ -110,7 +111,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryComm
110
111
111
112
$ this ->assertNull ($ currentCommand );
112
113
113
- $ promise = $ connection ->query ('SELECT 1 ' );
114
+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
114
115
115
116
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
116
117
@@ -139,7 +140,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenIdlePerio
139
140
140
141
$ this ->assertNull ($ currentCommand );
141
142
142
- $ promise = $ connection ->query ('SELECT 1 ' );
143
+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
143
144
144
145
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
145
146
@@ -166,7 +167,7 @@ public function testQueryWillReturnResolvedPromiseAndNotStartIdleTimerWhenIdlePe
166
167
167
168
$ this ->assertNull ($ currentCommand );
168
169
169
- $ promise = $ connection ->query ('SELECT 1 ' );
170
+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
170
171
171
172
$ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
172
173
@@ -195,7 +196,7 @@ public function testQueryWillReturnRejectedPromiseAndStartIdleTimerWhenQueryComm
195
196
196
197
$ this ->assertNull ($ currentCommand );
197
198
198
- $ promise = $ connection ->query ('SELECT 1 ' );
199
+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
199
200
200
201
$ promise ->then (null , $ this ->expectCallableOnce ());
201
202
@@ -230,7 +231,7 @@ public function testQueryFollowedByIdleTimerWillQuitUnderlyingConnectionAndEmitC
230
231
231
232
$ this ->assertNull ($ currentCommand );
232
233
233
- $ connection ->query ('SELECT 1 ' );
234
+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
234
235
235
236
$ this ->assertNotNull ($ currentCommand );
236
237
$ currentCommand ->emit ('success ' );
@@ -269,7 +270,7 @@ public function testQueryFollowedByIdleTimerWillQuitUnderlyingConnectionAndEmitC
269
270
270
271
$ this ->assertNull ($ currentCommand );
271
272
272
- $ connection ->query ('SELECT 1 ' );
273
+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
273
274
274
275
$ this ->assertNotNull ($ currentCommand );
275
276
$ currentCommand ->emit ('success ' );
@@ -300,8 +301,8 @@ public function testQueryTwiceWillEnqueueSecondQueryWithoutStartingIdleTimerWhen
300
301
301
302
$ this ->assertNull ($ currentCommand );
302
303
303
- $ connection ->query ('SELECT 1 ' );
304
- $ connection ->query ('SELECT 2 ' );
304
+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
305
+ $ connection ->query (new Query ( 'SELECT 2 ' ) );
305
306
306
307
$ this ->assertNotNull ($ currentCommand );
307
308
$ currentCommand ->emit ('success ' );
@@ -328,12 +329,12 @@ public function testQueryTwiceAfterIdleTimerWasStartedWillCancelIdleTimerAndEnqu
328
329
329
330
$ this ->assertNull ($ currentCommand );
330
331
331
- $ connection ->query ('SELECT 1 ' );
332
+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
332
333
333
334
$ this ->assertNotNull ($ currentCommand );
334
335
$ currentCommand ->emit ('success ' );
335
336
336
- $ connection ->query ('SELECT 2 ' );
337
+ $ connection ->query (new Query ( 'SELECT 2 ' ) );
337
338
}
338
339
339
340
public function testQueryStreamWillEnqueueOneCommand ()
@@ -350,7 +351,7 @@ public function testQueryStreamWillEnqueueOneCommand()
350
351
$ loop ->expects ($ this ->never ())->method ('addTimer ' );
351
352
352
353
$ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
353
- $ conn ->queryStream ('SELECT 1 ' );
354
+ $ conn ->queryStream (new Query ( 'SELECT 1 ' ) );
354
355
}
355
356
356
357
public function testQueryStreamWillReturnStreamThatWillEmitEndEventAndStartIdleTimerWhenQueryCommandEmitsSuccess ()
@@ -374,7 +375,7 @@ public function testQueryStreamWillReturnStreamThatWillEmitEndEventAndStartIdleT
374
375
375
376
$ this ->assertNull ($ currentCommand );
376
377
377
- $ stream = $ connection ->queryStream ('SELECT 1 ' );
378
+ $ stream = $ connection ->queryStream (new Query ( 'SELECT 1 ' ) );
378
379
379
380
$ stream ->on ('end ' , $ this ->expectCallableOnce ());
380
381
$ stream ->on ('close ' , $ this ->expectCallableOnce ());
@@ -404,7 +405,7 @@ public function testQueryStreamWillReturnStreamThatWillEmitErrorEventAndStartIdl
404
405
405
406
$ this ->assertNull ($ currentCommand );
406
407
407
- $ stream = $ connection ->queryStream ('SELECT 1 ' );
408
+ $ stream = $ connection ->queryStream (new Query ( 'SELECT 1 ' ) );
408
409
409
410
$ stream ->on ('error ' , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('RuntimeException ' )));
410
411
$ stream ->on ('close ' , $ this ->expectCallableOnce ());
@@ -641,7 +642,7 @@ public function testQueryAfterQuitRejectsImmediately()
641
642
642
643
$ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
643
644
$ conn ->quit ();
644
- $ promise = $ conn ->query ('SELECT 1 ' );
645
+ $ promise = $ conn ->query (new Query ( 'SELECT 1 ' ) );
645
646
646
647
$ promise ->then (null , $ this ->expectCallableOnceWith (
647
648
$ this ->logicalAnd (
@@ -668,7 +669,7 @@ public function testQueryAfterCloseRejectsImmediately()
668
669
669
670
$ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
670
671
$ conn ->close ();
671
- $ promise = $ conn ->query ('SELECT 1 ' );
672
+ $ promise = $ conn ->query (new Query ( 'SELECT 1 ' ) );
672
673
673
674
$ promise ->then (null , $ this ->expectCallableOnceWith (
674
675
$ this ->logicalAnd (
@@ -697,7 +698,7 @@ public function testQueryStreamAfterQuitThrows()
697
698
$ conn ->quit ();
698
699
699
700
try {
700
- $ conn ->queryStream ('SELECT 1 ' );
701
+ $ conn ->queryStream (new Query ( 'SELECT 1 ' ) );
701
702
} catch (\RuntimeException $ e ) {
702
703
$ this ->assertEquals ('Connection closing (ENOTCONN) ' , $ e ->getMessage ());
703
704
$ this ->assertEquals (defined ('SOCKET_ENOTCONN ' ) ? SOCKET_ENOTCONN : 107 , $ e ->getCode ());
0 commit comments