File tree 3 files changed +28
-2
lines changed
tests/Integration/CachedBuilder
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function __construct(
24
24
$ model ,
25
25
$ query ,
26
26
$ macroKey ,
27
- $ withoutScopes ,
27
+ array $ withoutScopes ,
28
28
$ withoutAllScopes
29
29
) {
30
30
$ this ->eagerLoad = $ eagerLoad ;
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ trait Caching
16
16
protected $ isCachable = true ;
17
17
protected $ scopesAreApplied = false ;
18
18
protected $ macroKey = "" ;
19
- protected $ withoutScopes = null ;
19
+ protected $ withoutScopes = [] ;
20
20
protected $ withoutAllScopes = false ;
21
21
22
22
public function __call ($ method , $ parameters )
Original file line number Diff line number Diff line change @@ -156,6 +156,32 @@ public function testGlobalScopesWhenSwitchingContextUsingGetMethod()
156
156
$ this ->assertEquals ("B " , $ authorsB ->first ());
157
157
}
158
158
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
+
159
185
public function testLocalScopesInRelationship ()
160
186
{
161
187
$ first = "A " ;
You can’t perform that action at this time.
0 commit comments