@@ -71,13 +71,6 @@ protected function defineDatabaseMigrations(): void
7171 });
7272 }
7373
74- public function test_passes_through_method_calls (): void
75- {
76- $ query = $ this ->app ->make ('db ' )->table ('users ' )->cache ()->where ('id ' , 1 );
77-
78- static ::assertSame ([], $ query ->getConnection ()->getQueryLog ());
79- }
80-
8174 public function test_caches_base_query_into_default_store (): void
8275 {
8376 $ get = $ this ->app ->make ('db ' )->table ('users ' )->cache ()->where ('id ' , 1 )->get ();
@@ -874,6 +867,10 @@ public function test_pass_through_methods_to_wrapped_connection(): void
874867 $ connection ->setDatabaseName ('foo ' );
875868
876869 static ::assertSame ('foo ' , $ connection ->getDatabaseName ());
870+
871+ $ query = $ this ->app ->make ('db ' )->table ('users ' )->cache ()->where ('id ' , 1 );
872+
873+ static ::assertSame ([], $ query ->getConnection ()->getQueryLog ());
877874 }
878875
879876 public function test_pass_through_properties_set_and_get (): void
@@ -916,6 +913,24 @@ public function test_sets_custom_query_hasher(): void
916913
917914 static ::assertTrue ($ this ->app ->make ('cache ' )->has ('cache-query|test_hash ' ));
918915 }
916+
917+ public function test_base_query_uses_cache_callback (): void
918+ {
919+ $ hash = 'cache-query|fj8Xyz4K1Zh0tdAamPbG1A ' ;
920+
921+ $ repository = $ this ->mock (Repository::class);
922+ $ repository ->expects ('flexible ' )->never ();
923+ $ repository ->expects ('put ' )->with ($ hash , Mockery::type ('array ' ), [5 , 300 ])->once ();
924+ $ repository ->expects ('getMultiple ' )->with ([$ hash , '' ])->times (1 )->andReturn (['' => null , $ hash => null ]);
925+
926+ $ this ->mock ('cache ' )->expects ('store ' )->with (null )->andReturn ($ repository );
927+
928+ $ this ->app ->make ('db ' )->table ('users ' )->where ('id ' , 1 )->cache (function ($ cache ) {
929+ static ::assertInstanceOf (Cache::class, $ cache );
930+
931+ $ cache ->ttl ([5 , 300 ]);
932+ })->first ();
933+ }
919934}
920935
921936class User extends Authenticatable
0 commit comments