@@ -67,7 +67,7 @@ public function testGlobalScopesAreCached()
67
67
->first ();
68
68
$ authors = (new AuthorBeginsWithScoped )
69
69
->get ();
70
- $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped-name_like_A% " );
70
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped-name_like_A%0=A%25 " );
71
71
$ tags = ["genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped " ];
72
72
73
73
$ cachedResults = $ this ->cache ()
@@ -89,7 +89,7 @@ public function testInlineGlobalScopesAreCached()
89
89
->first ();
90
90
$ authors = (new AuthorWithInlineGlobalScope )
91
91
->get ();
92
- $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthorwithinlineglobalscope-authors.deleted_at_null-name_like_A% " );
92
+ $ key = sha1 ("genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthorwithinlineglobalscope-authors.deleted_at_null-name_like_A%0=A%25 " );
93
93
$ tags = ["genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthorwithinlineglobalscope " ];
94
94
95
95
$ cachedResults = $ this ->cache ()
@@ -103,7 +103,33 @@ public function testInlineGlobalScopesAreCached()
103
103
$ this ->assertTrue ($ liveResults ->contains ($ author ));
104
104
}
105
105
106
- public function testGlobalScopesWhenSwitchingContext ()
106
+ public function testGlobalScopesWhenSwitchingContextUsingAllMethod ()
107
+ {
108
+ factory (Author::class, 200 )->create ();
109
+ $ user = factory (User::class)->create (["name " => "Andrew Junior " ]);
110
+ $ this ->actingAs ($ user );
111
+ $ authorsA = (new AuthorBeginsWithScoped )
112
+ ->all ()
113
+ ->map (function ($ author ) {
114
+ return (new Str )->substr ($ author ->name , 0 , 1 );
115
+ })
116
+ ->unique ();
117
+ $ user = factory (User::class)->create (["name " => "Barry Barry Barry " ]);
118
+ $ this ->actingAs ($ user );
119
+ $ authorsB = (new AuthorBeginsWithScoped )
120
+ ->all ()
121
+ ->map (function ($ author ) {
122
+ return (new Str )->substr ($ author ->name , 0 , 1 );
123
+ })
124
+ ->unique ();
125
+
126
+ $ this ->assertCount (1 , $ authorsA );
127
+ $ this ->assertCount (1 , $ authorsB );
128
+ $ this ->assertEquals ("A " , $ authorsA ->first ());
129
+ $ this ->assertEquals ("B " , $ authorsB ->first ());
130
+ }
131
+
132
+ public function testGlobalScopesWhenSwitchingContextUsingGetMethod ()
107
133
{
108
134
factory (Author::class, 200 )->create ();
109
135
$ user = factory (User::class)->create (["name " => "Anton Junior " ]);
0 commit comments