File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
tests/Integration/CachedBuilder Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function __construct(
2424 $ model ,
2525 $ query ,
2626 $ macroKey ,
27- $ withoutScopes ,
27+ array $ withoutScopes ,
2828 $ withoutAllScopes
2929 ) {
3030 $ this ->eagerLoad = $ eagerLoad ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ trait Caching
1616 protected $ isCachable = true ;
1717 protected $ scopesAreApplied = false ;
1818 protected $ macroKey = "" ;
19- protected $ withoutScopes = null ;
19+ protected $ withoutScopes = [] ;
2020 protected $ withoutAllScopes = false ;
2121
2222 public function __call ($ method , $ parameters )
Original file line number Diff line number Diff line change @@ -156,6 +156,32 @@ public function testGlobalScopesWhenSwitchingContextUsingGetMethod()
156156 $ this ->assertEquals ("B " , $ authorsB ->first ());
157157 }
158158
159+ public function testWithoutGlobalScopes ()
160+ {
161+ factory (Author::class, 200 )->create ();
162+ $ user = factory (User::class)->create (["name " => "Andrew Junior " ]);
163+ $ this ->actingAs ($ user );
164+ $ authorsA = (new AuthorBeginsWithScoped )
165+ ->withoutGlobalScopes ()
166+ ->get ()
167+ ->map (function ($ author ) {
168+ return (new Str )->substr ($ author ->name , 0 , 1 );
169+ })
170+ ->unique ();
171+ $ user = factory (User::class)->create (["name " => "Barry Barry Barry " ]);
172+ $ this ->actingAs ($ user );
173+ $ authorsB = (new AuthorBeginsWithScoped )
174+ ->withoutGlobalScopes ()
175+ ->get ()
176+ ->map (function ($ author ) {
177+ return (new Str )->substr ($ author ->name , 0 , 1 );
178+ })
179+ ->unique ();
180+
181+ $ this ->assertGreaterThan (1 , count ($ authorsA ));
182+ $ this ->assertGreaterThan (1 , count ($ authorsB ));
183+ }
184+
159185 public function testLocalScopesInRelationship ()
160186 {
161187 $ first = "A " ;
You can’t perform that action at this time.
0 commit comments