22
33namespace MongoDB \Laravel \Tests \Eloquent ;
44
5+ use Illuminate \Support \Facades \DB ;
56use MongoDB \Laravel \Eloquent \Model ;
67use MongoDB \Laravel \Tests \TestCase ;
78
9+ use function count ;
10+
811/** Copied from {@see \Illuminate\Tests\Integration\Database\EloquentWithCountTest\EloquentWithCountTest} */
912class EloquentWithCountTest extends TestCase
1013{
@@ -37,6 +40,7 @@ public function testItBasic()
3740
3841 public function testWithMultipleResults ()
3942 {
43+ $ connection = DB ::connection ('mongodb ' );
4044 $ ones = [
4145 EloquentWithCountModel1::create (['id ' => 1 ]),
4246 EloquentWithCountModel1::create (['id ' => 2 ]),
@@ -50,6 +54,7 @@ public function testWithMultipleResults()
5054 $ ones [2 ]->twos ()->create (['value ' => 1 ]);
5155 $ ones [2 ]->twos ()->create (['value ' => 2 ]);
5256
57+ $ connection ->enableQueryLog ();
5358 $ results = EloquentWithCountModel1::withCount ([
5459 'twos ' => function ($ query ) {
5560 $ query ->where ('value ' , '>= ' , 2 );
@@ -61,6 +66,9 @@ public function testWithMultipleResults()
6166 ['id ' => 2 , 'twos_count ' => 0 ],
6267 ['id ' => 3 , 'twos_count ' => 1 ],
6368 ], $ results ->get ()->toArray ());
69+
70+ $ connection ->disableQueryLog ();
71+ $ this ->assertEquals (2 , count ($ connection ->getQueryLog ()));
6472 }
6573
6674 public function testGlobalScopes ()
0 commit comments