@@ -14,7 +14,7 @@ class FindOneTest extends TestCase
1414 * @runInSeparateProcess
1515 * @preserveGlobalState disabled
1616 */
17- public function testFindOne (): void
17+ public function testEloquentFindOne (): void
1818 {
1919 require_once __DIR__ . '/Movie.php ' ;
2020
@@ -25,12 +25,29 @@ public function testFindOne(): void
2525
2626 // begin-eloquent-find-one
2727 $ movie = Movie::where ('directors ' , 'Rob Reiner ' )
28- ->orderBy ('_id ' )
28+ ->orderBy ('id ' )
2929 ->first ();
3030
3131 echo $ movie ->toJson ();
3232 // end-eloquent-find-one
3333
34+ $ this ->assertInstanceOf (Movie::class, $ movie );
35+ $ this ->expectOutputRegex ('/^{"title":"The Shawshank Redemption","directors":\["Frank Darabont","Rob Reiner"\],"id":"[a-z0-9]{24}"}$/ ' );
36+ }
37+
38+ /**
39+ * @runInSeparateProcess
40+ * @preserveGlobalState disabled
41+ */
42+ public function testQBFindOne (): void
43+ {
44+ require_once __DIR__ . '/Movie.php ' ;
45+
46+ Movie::truncate ();
47+ Movie::insert ([
48+ ['title ' => 'The Shawshank Redemption ' , 'directors ' => ['Frank Darabont ' , 'Rob Reiner ' ]],
49+ ]);
50+
3451 // begin-qb-find-one
3552 $ movie = DB ::table ('movies ' )
3653 ->where ('directors ' , 'Rob Reiner ' )
@@ -40,8 +57,7 @@ public function testFindOne(): void
4057 echo $ movie ['title ' ];
4158 // end-qb-find-one
4259
43- $ this ->assertInstanceOf (Movie::class, $ movie );
4460 $ this ->assertSame ($ movie ['title ' ], 'The Shawshank Redemption ' );
45- $ this ->expectOutputString ('{"_id":"679cdb4834e26dc5370de462","title":"The Shawshank Redemption","directors":["Frank Darabont","Rob Reiner"]} The Shawshank Redemption ' );
61+ $ this ->expectOutputString ('The Shawshank Redemption ' );
4662 }
4763}
0 commit comments