Skip to content

Commit b075e9a

Browse files
committed
Added additional whereraw test
1 parent 1655e8f commit b075e9a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Integration/CachedBuilder/WhereRawTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,25 @@ public function testNestedWhereRawWithBindings()
102102

103103
$this->assertEquals($books->pluck("id"), $uncachedBooks->pluck("id"));
104104
}
105+
106+
public function testWhereRawParametersCacheUniquely()
107+
{
108+
$book1 = (new UncachedBook)->first();
109+
$book2 = (new UncachedBook)->orderBy("id", "DESC")->first();
110+
111+
$result1 = (new Book)
112+
->whereRaw("id = ?", [$book1->id])
113+
->get();
114+
$result2 = (new Book)
115+
->whereRaw("id = ?", [$book2->id])
116+
->get();
117+
$key1 = sha1("genealabs:laravel-model-caching:testing::memory::books:genealabslaravelmodelcachingtestsfixturesbook-_and_id_=_{$book1->id}");
118+
$key2 = sha1("genealabs:laravel-model-caching:testing::memory::books:genealabslaravelmodelcachingtestsfixturesbook-_and_id_=_{$book2->id}");
119+
$tags = ['genealabs:laravel-model-caching:testing::memory::genealabslaravelmodelcachingtestsfixturesbook'];
120+
$cachedBook1 = $this->cache()->tags($tags)->get($key1)['value'];
121+
$cachedBook2 = $this->cache()->tags($tags)->get($key2)['value'];
122+
123+
$this->assertEquals($cachedBook1->first()->title, $result1->first()->title);
124+
$this->assertEquals($cachedBook2->first()->title, $result2->first()->title);
125+
}
105126
}

0 commit comments

Comments
 (0)