File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,13 @@ public function avg($column)
2323 return $ this ->cachedValue (func_get_args (), $ cacheKey );
2424 }
2525
26- public function count ($ columns = [ "* " ] )
26+ public function count ($ columns = "* " )
2727 {
2828 if (! $ this ->isCachable ()) {
2929 return parent ::count ($ columns );
3030 }
3131
32- $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-count " );
32+ $ cacheKey = $ this ->makeCacheKey ([ $ columns] , null , "-count " );
3333
3434 return $ this ->cachedValue (func_get_args (), $ cacheKey );
3535 }
Original file line number Diff line number Diff line change @@ -243,6 +243,28 @@ public function testCountModelResultsCreatesCache()
243243 $ this ->assertEquals ($ liveResults , $ cachedResults );
244244 }
245245
246+ public function testCountWithStringCreatesCache ()
247+ {
248+ $ authors = (new Author )
249+ ->with ('books ' , 'profile ' )
250+ ->count ("id " );
251+ $ key = sha1 ('genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesauthor_id-books-profile-count ' );
252+ $ tags = [
253+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesauthor ' ,
254+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesbook ' ,
255+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesprofile ' ,
256+ ];
257+
258+ $ cachedResults = $ this ->cache ()->tags ($ tags )
259+ ->get ($ key )['value ' ];
260+ $ liveResults = (new UncachedAuthor )
261+ ->with ('books ' , 'profile ' )
262+ ->count ("id " );
263+
264+ $ this ->assertEquals ($ authors , $ cachedResults );
265+ $ this ->assertEquals ($ liveResults , $ cachedResults );
266+ }
267+
246268 public function testFindModelResultsCreatesCache ()
247269 {
248270 $ author = collect ()->push ((new Author )->find (1 ));
You can’t perform that action at this time.
0 commit comments