@@ -658,7 +658,7 @@ public function testExecRejectsWhenAlreadyClosed($flag)
658
658
* @dataProvider provideSocketFlags
659
659
* @param bool $flag
660
660
*/
661
- public function testQueryInsertResolvesWithResultWithLastInsertIdAndRunsUntilQuit ($ flag )
661
+ public function testQueryInsertResolvesWithEmptyResultSetWithLastInsertIdAndRunsUntilQuit ($ flag )
662
662
{
663
663
$ loop = React \EventLoop \Factory::create ();
664
664
$ factory = new Factory ($ loop );
@@ -673,15 +673,50 @@ public function testQueryInsertResolvesWithResultWithLastInsertIdAndRunsUntilQui
673
673
$ promise ->then (function (DatabaseInterface $ db ) use (&$ data ){
674
674
$ db ->exec ('CREATE TABLE foo (id INTEGER PRIMARY KEY AUTOINCREMENT, bar STRING) ' );
675
675
$ 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 ' );
678
711
679
712
$ db ->quit ();
680
713
});
681
714
682
715
$ loop ->run ();
683
716
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 );
685
720
}
686
721
687
722
protected function expectCallableNever ()
0 commit comments