@@ -14,7 +14,7 @@ class FindOneTest extends TestCase
14
14
* @runInSeparateProcess
15
15
* @preserveGlobalState disabled
16
16
*/
17
- public function testFindOne (): void
17
+ public function testEloquentFindOne (): void
18
18
{
19
19
require_once __DIR__ . '/Movie.php ' ;
20
20
@@ -25,12 +25,29 @@ public function testFindOne(): void
25
25
26
26
// begin-eloquent-find-one
27
27
$ movie = Movie::where ('directors ' , 'Rob Reiner ' )
28
- ->orderBy ('_id ' )
28
+ ->orderBy ('id ' )
29
29
->first ();
30
30
31
31
echo $ movie ->toJson ();
32
32
// end-eloquent-find-one
33
33
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
+
34
51
// begin-qb-find-one
35
52
$ movie = DB ::table ('movies ' )
36
53
->where ('directors ' , 'Rob Reiner ' )
@@ -40,8 +57,7 @@ public function testFindOne(): void
40
57
echo $ movie ['title ' ];
41
58
// end-qb-find-one
42
59
43
- $ this ->assertInstanceOf (Movie::class, $ movie );
44
60
$ 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 ' );
46
62
}
47
63
}
0 commit comments