File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -73,4 +73,28 @@ public function testAllMethodCachingCanBeDisabledViaConfig()
7373 $ this ->assertNotEmpty ($ authors );
7474 $ this ->assertCount (10 , $ authors );
7575 }
76+
77+ public function testWhereHasIsBeingCached ()
78+ {
79+ $ books = (new Book )
80+ ->with ('author ' )
81+ ->whereHas ('author ' , function ($ query ) {
82+ $ query ->whereId ('1 ' );
83+ })
84+ ->get ();
85+
86+ $ key = sha1 ('genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesbook_exists_and_books.author_id_=_authors.id-id_=_1-author ' );
87+ $ tags = [
88+ 'genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesbook ' ,
89+ 'genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesauthor ' ,
90+ ];
91+
92+ $ cachedResults = $ this
93+ ->cache ()
94+ ->tags ($ tags )
95+ ->get ($ key )['value ' ];
96+
97+ $ this ->assertEquals (1 , $ books ->first ()->author ->id );
98+ $ this ->assertEquals (1 , $ cachedResults ->first ()->author ->id );
99+ }
76100}
You can’t perform that action at this time.
0 commit comments