33namespace React \Tests \Mysql \Io ;
44
55use React \Mysql \Io \Connection ;
6+ use React \Mysql \Io \Query ;
67use React \Tests \Mysql \BaseTestCase ;
78
89class ConnectionTest extends BaseTestCase
@@ -22,7 +23,7 @@ public function testIsBusyReturnsTrueWhenParserIsBusy()
2223
2324 $ connection = new Connection ($ stream , $ executor , $ parser , $ loop , null );
2425
25- $ connection ->query ('SELECT 1 ' );
26+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
2627
2728 $ this ->assertTrue ($ connection ->isBusy ());
2829 }
@@ -57,7 +58,7 @@ public function testQueryWillEnqueueOneCommand()
5758 $ loop ->expects ($ this ->never ())->method ('addTimer ' );
5859
5960 $ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
60- $ conn ->query ('SELECT 1 ' );
61+ $ conn ->query (new Query ( 'SELECT 1 ' ) );
6162 }
6263
6364 public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryCommandEmitsSuccess ()
@@ -81,7 +82,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryComm
8182
8283 $ this ->assertNull ($ currentCommand );
8384
84- $ promise = $ connection ->query ('SELECT 1 ' );
85+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
8586
8687 $ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
8788
@@ -110,7 +111,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenQueryComm
110111
111112 $ this ->assertNull ($ currentCommand );
112113
113- $ promise = $ connection ->query ('SELECT 1 ' );
114+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
114115
115116 $ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
116117
@@ -139,7 +140,7 @@ public function testQueryWillReturnResolvedPromiseAndStartIdleTimerWhenIdlePerio
139140
140141 $ this ->assertNull ($ currentCommand );
141142
142- $ promise = $ connection ->query ('SELECT 1 ' );
143+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
143144
144145 $ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
145146
@@ -166,7 +167,7 @@ public function testQueryWillReturnResolvedPromiseAndNotStartIdleTimerWhenIdlePe
166167
167168 $ this ->assertNull ($ currentCommand );
168169
169- $ promise = $ connection ->query ('SELECT 1 ' );
170+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
170171
171172 $ promise ->then ($ this ->expectCallableOnceWith ($ this ->isInstanceOf ('React\Mysql\MysqlResult ' )));
172173
@@ -195,7 +196,7 @@ public function testQueryWillReturnRejectedPromiseAndStartIdleTimerWhenQueryComm
195196
196197 $ this ->assertNull ($ currentCommand );
197198
198- $ promise = $ connection ->query ('SELECT 1 ' );
199+ $ promise = $ connection ->query (new Query ( 'SELECT 1 ' ) );
199200
200201 $ promise ->then (null , $ this ->expectCallableOnce ());
201202
@@ -230,7 +231,7 @@ public function testQueryFollowedByIdleTimerWillQuitUnderlyingConnectionAndEmitC
230231
231232 $ this ->assertNull ($ currentCommand );
232233
233- $ connection ->query ('SELECT 1 ' );
234+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
234235
235236 $ this ->assertNotNull ($ currentCommand );
236237 $ currentCommand ->emit ('success ' );
@@ -269,7 +270,7 @@ public function testQueryFollowedByIdleTimerWillQuitUnderlyingConnectionAndEmitC
269270
270271 $ this ->assertNull ($ currentCommand );
271272
272- $ connection ->query ('SELECT 1 ' );
273+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
273274
274275 $ this ->assertNotNull ($ currentCommand );
275276 $ currentCommand ->emit ('success ' );
@@ -300,8 +301,8 @@ public function testQueryTwiceWillEnqueueSecondQueryWithoutStartingIdleTimerWhen
300301
301302 $ this ->assertNull ($ currentCommand );
302303
303- $ connection ->query ('SELECT 1 ' );
304- $ connection ->query ('SELECT 2 ' );
304+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
305+ $ connection ->query (new Query ( 'SELECT 2 ' ) );
305306
306307 $ this ->assertNotNull ($ currentCommand );
307308 $ currentCommand ->emit ('success ' );
@@ -328,12 +329,12 @@ public function testQueryTwiceAfterIdleTimerWasStartedWillCancelIdleTimerAndEnqu
328329
329330 $ this ->assertNull ($ currentCommand );
330331
331- $ connection ->query ('SELECT 1 ' );
332+ $ connection ->query (new Query ( 'SELECT 1 ' ) );
332333
333334 $ this ->assertNotNull ($ currentCommand );
334335 $ currentCommand ->emit ('success ' );
335336
336- $ connection ->query ('SELECT 2 ' );
337+ $ connection ->query (new Query ( 'SELECT 2 ' ) );
337338 }
338339
339340 public function testQueryStreamWillEnqueueOneCommand ()
@@ -350,7 +351,7 @@ public function testQueryStreamWillEnqueueOneCommand()
350351 $ loop ->expects ($ this ->never ())->method ('addTimer ' );
351352
352353 $ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
353- $ conn ->queryStream ('SELECT 1 ' );
354+ $ conn ->queryStream (new Query ( 'SELECT 1 ' ) );
354355 }
355356
356357 public function testQueryStreamWillReturnStreamThatWillEmitEndEventAndStartIdleTimerWhenQueryCommandEmitsSuccess ()
@@ -374,7 +375,7 @@ public function testQueryStreamWillReturnStreamThatWillEmitEndEventAndStartIdleT
374375
375376 $ this ->assertNull ($ currentCommand );
376377
377- $ stream = $ connection ->queryStream ('SELECT 1 ' );
378+ $ stream = $ connection ->queryStream (new Query ( 'SELECT 1 ' ) );
378379
379380 $ stream ->on ('end ' , $ this ->expectCallableOnce ());
380381 $ stream ->on ('close ' , $ this ->expectCallableOnce ());
@@ -404,7 +405,7 @@ public function testQueryStreamWillReturnStreamThatWillEmitErrorEventAndStartIdl
404405
405406 $ this ->assertNull ($ currentCommand );
406407
407- $ stream = $ connection ->queryStream ('SELECT 1 ' );
408+ $ stream = $ connection ->queryStream (new Query ( 'SELECT 1 ' ) );
408409
409410 $ stream ->on ('error ' , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('RuntimeException ' )));
410411 $ stream ->on ('close ' , $ this ->expectCallableOnce ());
@@ -641,7 +642,7 @@ public function testQueryAfterQuitRejectsImmediately()
641642
642643 $ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
643644 $ conn ->quit ();
644- $ promise = $ conn ->query ('SELECT 1 ' );
645+ $ promise = $ conn ->query (new Query ( 'SELECT 1 ' ) );
645646
646647 $ promise ->then (null , $ this ->expectCallableOnceWith (
647648 $ this ->logicalAnd (
@@ -668,7 +669,7 @@ public function testQueryAfterCloseRejectsImmediately()
668669
669670 $ conn = new Connection ($ stream , $ executor , $ parser , $ loop , null );
670671 $ conn ->close ();
671- $ promise = $ conn ->query ('SELECT 1 ' );
672+ $ promise = $ conn ->query (new Query ( 'SELECT 1 ' ) );
672673
673674 $ promise ->then (null , $ this ->expectCallableOnceWith (
674675 $ this ->logicalAnd (
@@ -697,7 +698,7 @@ public function testQueryStreamAfterQuitThrows()
697698 $ conn ->quit ();
698699
699700 try {
700- $ conn ->queryStream ('SELECT 1 ' );
701+ $ conn ->queryStream (new Query ( 'SELECT 1 ' ) );
701702 } catch (\RuntimeException $ e ) {
702703 $ this ->assertEquals ('Connection closing (ENOTCONN) ' , $ e ->getMessage ());
703704 $ this ->assertEquals (defined ('SOCKET_ENOTCONN ' ) ? SOCKET_ENOTCONN : 107 , $ e ->getCode ());
0 commit comments