@@ -658,7 +658,7 @@ public function testExecRejectsWhenAlreadyClosed($flag)
658658 * @dataProvider provideSocketFlags
659659 * @param bool $flag
660660 */
661- public function testQueryInsertResolvesWithResultWithLastInsertIdAndRunsUntilQuit ($ flag )
661+ public function testQueryInsertResolvesWithEmptyResultSetWithLastInsertIdAndRunsUntilQuit ($ flag )
662662 {
663663 $ loop = React \EventLoop \Factory::create ();
664664 $ factory = new Factory ($ loop );
@@ -673,15 +673,50 @@ public function testQueryInsertResolvesWithResultWithLastInsertIdAndRunsUntilQui
673673 $ promise ->then (function (DatabaseInterface $ db ) use (&$ data ){
674674 $ db ->exec ('CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT, bar STRING) ' );
675675 $ db ->query ('INSERT INTO foo (bar) VALUES (?) ' , ['test ' ])->then (function (Result $ result ) use (&$ data ) {
676- $ data = $ result ->insertId ;
677- });
676+ $ data = $ result ;
677+ }, 'printf ' );
678+
679+ $ db ->quit ();
680+ });
681+
682+ $ loop ->run ();
683+
684+ $ this ->assertInstanceOf ('Clue\React\SQLite\Result ' , $ data );
685+ $ this ->assertSame (1 , $ data ->insertId );
686+ $ this ->assertNull ($ data ->columns );
687+ $ this ->assertNull ($ data ->rows );
688+ }
689+
690+ /**
691+ * @dataProvider provideSocketFlags
692+ * @param bool $flag
693+ */
694+ public function testQuerySelectEmptyResolvesWithEmptyResultSetWithColumnsAndNoRowsAndRunsUntilQuit ($ flag )
695+ {
696+ $ loop = React \EventLoop \Factory::create ();
697+ $ factory = new Factory ($ loop );
698+
699+ $ ref = new ReflectionProperty ($ factory , 'useSocket ' );
700+ $ ref ->setAccessible (true );
701+ $ ref ->setValue ($ factory , $ flag );
702+
703+ $ promise = $ factory ->open (':memory: ' );
704+
705+ $ data = null ;
706+ $ promise ->then (function (DatabaseInterface $ db ) use (&$ data ){
707+ $ db ->exec ('CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT, bar STRING) ' );
708+ $ db ->query ('SELECT * FROM foo LIMIT 0 ' )->then (function (Result $ result ) use (&$ data ) {
709+ $ data = $ result ;
710+ }, 'printf ' );
678711
679712 $ db ->quit ();
680713 });
681714
682715 $ loop ->run ();
683716
684- $ this ->assertSame (1 , $ data );
717+ $ this ->assertInstanceOf ('Clue\React\SQLite\Result ' , $ data );
718+ $ this ->assertSame (['id ' , 'bar ' ], $ data ->columns );
719+ $ this ->assertSame ([], $ data ->rows );
685720 }
686721
687722 protected function expectCallableNever ()
0 commit comments