Skip to content

Commit b581f10

Browse files
committed
Merge branch 'hotfix/fix-wherehas-caching'
2 parents 8b0f72e + 8431f38 commit b581f10

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Unit/CachedModelTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,28 @@ public function testAllMethodCachingCanBeDisabledViaConfig()
7373
$this->assertNotEmpty($authors);
7474
$this->assertCount(10, $authors);
7575
}
76+
77+
public function testWhereHasIsBeingCached()
78+
{
79+
$books = (new Book)
80+
->with('author')
81+
->whereHas('author', function ($query) {
82+
$query->whereId('1');
83+
})
84+
->get();
85+
86+
$key = sha1('genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesbook_exists_and_books.author_id_=_authors.id-id_=_1-author');
87+
$tags = [
88+
'genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesbook',
89+
'genealabs:laravel-model-caching:genealabslaravelmodelcachingtestsfixturesauthor',
90+
];
91+
92+
$cachedResults = $this
93+
->cache()
94+
->tags($tags)
95+
->get($key)['value'];
96+
97+
$this->assertEquals(1, $books->first()->author->id);
98+
$this->assertEquals(1, $cachedResults->first()->author->id);
99+
}
76100
}

0 commit comments

Comments
 (0)