@@ -67,7 +67,7 @@ public function testGlobalScopesAreCached()
6767 ->first ();
6868 $ authors = (new AuthorBeginsWithScoped )
6969 ->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 " );
7171 $ tags = ["genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthorbeginswithscoped " ];
7272
7373 $ cachedResults = $ this ->cache ()
@@ -89,7 +89,7 @@ public function testInlineGlobalScopesAreCached()
8989 ->first ();
9090 $ authors = (new AuthorWithInlineGlobalScope )
9191 ->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 " );
9393 $ tags = ["genealabs:laravel-model-caching:testing: {$ this ->testingSqlitePath }testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthorwithinlineglobalscope " ];
9494
9595 $ cachedResults = $ this ->cache ()
@@ -103,7 +103,33 @@ public function testInlineGlobalScopesAreCached()
103103 $ this ->assertTrue ($ liveResults ->contains ($ author ));
104104 }
105105
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 ()
107133 {
108134 factory (Author::class, 200 )->create ();
109135 $ user = factory (User::class)->create (["name " => "Anton Junior " ]);
0 commit comments