@@ -445,7 +445,7 @@ public function test_regenerates_cache_using_ttl_with_negative_number(): void
445445 static ::assertSame ('test ' , $ result ->name );
446446 }
447447
448- public function test_uses_flexible_caching_when_using_ttl_as_array_of_values (): void
448+ public function test_uses_db_flexible_caching_when_using_ttl_as_array_of_values (): void
449449 {
450450 if (! method_exists (CacheRepository::class, 'flexible ' )) {
451451 $ this ->markTestSkipped ('Cannot test flexible caching if repository does not implements it. ' );
@@ -463,6 +463,24 @@ public function test_uses_flexible_caching_when_using_ttl_as_array_of_values():
463463 $ this ->app ->make ('db ' )->table ('users ' )->where ('id ' , 1 )->cache ([5 , 300 ])->first ();
464464 }
465465
466+ public function test_uses_eloquent_flexible_caching_when_using_ttl_as_array_of_values (): void
467+ {
468+ if (! method_exists (CacheRepository::class, 'flexible ' )) {
469+ $ this ->markTestSkipped ('Cannot test flexible caching if repository does not implements it. ' );
470+ }
471+
472+ $ hash = 'cache-query|fj8Xyz4K1Zh0tdAamPbG1A ' ;
473+
474+ $ repository = $ this ->mock (CacheRepository::class);
475+ $ repository ->expects ('put ' )->never ();
476+ $ repository ->expects ('flexible ' )->with ($ hash , Mockery::type ('array ' ), [5 , 300 ])->once ();
477+ $ repository ->expects ('getMultiple ' )->with ([$ hash , '' ])->times (1 )->andReturn (['' => null , $ hash => null ]);
478+
479+ $ this ->mock ('cache ' )->shouldReceive ('store ' )->with (null )->andReturn ($ repository );
480+
481+ User::where ('id ' , 1 )->cache ([5 , 300 ])->first ();
482+ }
483+
466484 public function test_doesnt_uses_flexible_caching_if_repository_is_not_flexible (): void
467485 {
468486 $ hash = 'cache-query|fj8Xyz4K1Zh0tdAamPbG1A ' ;
0 commit comments