@@ -21,7 +21,7 @@ test(function () use ($context) {
2121 $ book ->delete ();
2222 Assert::exception (function () use ($ book ) {
2323 $ book ->toArray ();
24- }, Nette \InvalidStateException::class, ' Database refetch failed; row does not exist! ' );
24+ }, Nette \InvalidStateException::class, " Database refetch failed; row with signature '1' does not exist! " );
2525 }
2626
2727 $ booksSelection ->__destruct ();
@@ -42,13 +42,35 @@ test(function () use ($context) {
4242
4343 Assert::exception (function () use ($ book ) {
4444 $ book ->toArray ();
45- }, Nette \InvalidStateException::class, ' Database refetch failed; row does not exist! ' );
45+ }, Nette \InvalidStateException::class, " Database refetch failed; row with signature '2' does not exist! " );
4646 }
4747
4848 $ booksSelection ->__destruct ();
4949 }
5050});
5151
52+ test (function () use ($ context ) {
53+ $ books = [];
54+ for ($ i =0 ; $ i <2 ; $ i ++) {
55+ $ booksSelection = $ context ->table ('book ' )->where ('id IN ? ' , [3 ,4 ]);
56+ foreach ($ booksSelection as $ book ) {
57+ $ books [] = $ book ->id ;
58+
59+ if ($ i === 1 ) {
60+ $ context ->query ('DELETE FROM book WHERE id = 4 ' ); //After refetch second row is skipped
61+ $ book ->title ; // cause refetch
62+ }
63+
64+ $ booksSelection ->__destruct ();
65+ }
66+ }
67+ Assert::same ([
68+ 3 ,
69+ 4 ,
70+ 3 ,
71+ ], $ books );
72+ });
73+
5274test (function () use ($ context ) {
5375
5476 for ($ i =0 ; $ i <2 ; $ i ++) {
@@ -60,7 +82,7 @@ test(function () use ($context) {
6082 $ context ->query ('DELETE FROM book WHERE id = 3 ' );
6183 Assert::exception (function () use ($ book ) {
6284 $ book ->title ;
63- }, Nette \InvalidStateException::class, ' Database refetch failed; row does not exist! ' );
85+ }, Nette \InvalidStateException::class, " Database refetch failed; row with signature '3' does not exist! " );
6486 }
6587
6688 $ booksSelection ->__destruct ();
0 commit comments