File tree 1 file changed +25
-0
lines changed
tests/Integration/CachedBuilder
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,31 @@ public function testGlobalScopesWhenSwitchingContextUsingGetMethod()
156
156
$ this ->assertEquals ("B " , $ authorsB ->first ());
157
157
}
158
158
159
+ public function testGlobalScopesAreNotCachedWhenUsingWithoutGlobalScopes ()
160
+ {
161
+ $ user = factory (User::class)->create (["name " => "Abernathy Kings " ]);
162
+ $ this ->actingAs ($ user );
163
+ $ author = factory (UncachedAuthor::class, 1 )
164
+ ->create (['name ' => 'Alois ' ])
165
+ ->first ();
166
+ $ authors = (new AuthorBeginsWithScoped )
167
+ ->withoutGlobalScopes ()
168
+ ->get ();
169
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped " );
170
+ $ tags = ["genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped " ];
171
+
172
+ $ cachedResults = $ this ->cache ()
173
+ ->tags ($ tags )
174
+ ->get ($ key )['value ' ];
175
+ $ liveResults = (new UncachedAuthor )
176
+ ->nameStartsWith ("A " )
177
+ ->get ();
178
+
179
+ $ this ->assertTrue ($ authors ->contains ($ author ));
180
+ $ this ->assertTrue ($ cachedResults ->contains ($ author ));
181
+ $ this ->assertTrue ($ liveResults ->contains ($ author ));
182
+ }
183
+
159
184
public function testWithoutGlobalScopes ()
160
185
{
161
186
factory (Author::class, 200 )->create ();
You can’t perform that action at this time.
0 commit comments