Skip to content

Commit 5b084ce

Browse files
committed
Add test to check that nested relationship queries are cached
1 parent 049b5cf commit 5b084ce

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Unit/CachedBuilderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,25 @@ public function testScopeClauseParsing()
618618
$this->assertTrue($cachedResults->contains($author));
619619
$this->assertTrue($liveResults->contains($author));
620620
}
621+
622+
public function testRelationshipQueriesAreCached()
623+
{
624+
$books = (new Author)
625+
->first()
626+
->books()
627+
->get();
628+
$key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1-books.author_id_notnull';
629+
$tags = [
630+
'genealabslaravelmodelcachingtestsfixturesbook'
631+
];
632+
633+
$cachedResults = cache()->tags($tags)->get($key);
634+
$liveResults = (new UncachedAuthor)
635+
->first()
636+
->books()
637+
->get();
638+
639+
$this->assertTrue($cachedResults->diffAssoc($books)->isEmpty());
640+
$this->assertTrue($liveResults->diffAssoc($books)->isEmpty());
641+
}
621642
}

0 commit comments

Comments
 (0)