Skip to content

Commit d003028

Browse files
committed
Merge branch 'hotfix/fix-wherehas-nested-query-caching'
2 parents 62c4baf + db3046d commit d003028

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/Integration/CachedModelTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ public function testWhereHasIsBeingCached()
9898
$this->assertEquals(1, $cachedResults->first()->author->id);
9999
}
100100

101+
public function testWhereHasWithClosureIsBeingCached()
102+
{
103+
$books1 = (new Book)
104+
->with('author')
105+
->whereHas('author', function ($query) {
106+
$query->whereId(1);
107+
})
108+
->get()
109+
->keyBy('id');
110+
$books2 = (new Book)
111+
->with('author')
112+
->whereHas('author', function ($query) {
113+
$query->whereId(2);
114+
})
115+
->get()
116+
->keyBy('id');
117+
118+
$this->assertNotEmpty($books1->diffKeys($books2));
119+
}
120+
101121
public function testModelCacheDoesntInvalidateDuringCooldownPeriod()
102122
{
103123
$authors = (new Author)

0 commit comments

Comments
 (0)