Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c14f5e9

Browse files
author
Bill Harding
committed
Add unit test testGlobalScopesAreNotCachedWhenUsingWithoutGlobalScopes
1 parent 6089d00 commit c14f5e9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎tests/Integration/CachedBuilder/ScopeTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,31 @@ public function testGlobalScopesWhenSwitchingContextUsingGetMethod()
156156
$this->assertEquals("B", $authorsB->first());
157157
}
158158

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+
159184
public function testWithoutGlobalScopes()
160185
{
161186
factory(Author::class, 200)->create();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /