Skip to content

Commit ece9a9c

Browse files
authored
Merge pull request #297 from Hornet-Wing/feature/clear-cache-on-eager-loaded-non-cacheable-models-changing
Testing for clearing of eager loaded non cacheable relations
2 parents 0bd072f + f33b26d commit ece9a9c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Integration/CachedBuilderRelationshipsTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,27 @@ public function testWhereHasRelationship()
4444

4545
$this->assertEquals($books->pluck("id"), $uncachedBooks->pluck("id"));
4646
}
47+
48+
public function testNonCacheableEagerLoadedRelationsAreCleared()
49+
{
50+
$book = Book::with("uncachedStores")
51+
->whereHas("uncachedStores")
52+
->get()
53+
->first();
54+
55+
$store = $book->uncachedStores->first();
56+
$store->name = "Waterstones";
57+
$store->save();
58+
59+
$results = $this->cache()->tags([
60+
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook",
61+
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesuncachedstore"
62+
])
63+
->get(sha1(
64+
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:books:genealabslaravelmodelcachingtestsfixturesbook-exists-" .
65+
"and_books.id_=_book_store.book_id-testing:{$this->testingSqlitePath}testing.sqlite:uncachedStores"
66+
));
67+
68+
$this->assertNull($results);
69+
}
4770
}

0 commit comments

Comments
 (0)