Skip to content

Commit 6f8a5e6

Browse files
committed
WIP - increase coverage
1 parent 74076e2 commit 6f8a5e6

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/Builder.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ protected function cache(array $tags = [])
2020
return $cache;
2121
}
2222

23-
protected function getCacheKey(array $columns = ['*'], $ids = null) : string
23+
protected function getCacheKey(array $columns = ['*'], $idColumn = null) : string
2424
{
2525
$key = str_slug(get_class($this->model));
26-
27-
if ($ids) {
28-
$key .= '_' . (is_array($ids)
29-
? implode('_', $ids)
30-
: $ids);
31-
}
26+
$key .= $idColumn ? "_{$idColumn}" : '';
3227

3328
if ($columns !== ['*']) {
3429
$key .= '_' . implode('_', $columns);

tests/Unit/CachedBuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ public function testMinModelResultsCreatesCache()
351351
public function testPluckModelResultsCreatesCache()
352352
{
353353
$authors = (new Author)->with('books', 'profile')
354-
->pluck('id');
355-
$key = 'genealabslaravelmodelcachingtestsfixturesauthor_id-books-profile-pluck_id';
354+
->pluck('name', 'id');
355+
$key = 'genealabslaravelmodelcachingtestsfixturesauthor_name-books-profile-pluck_name_id';
356356
$tags = [
357357
'genealabslaravelmodelcachingtestsfixturesauthor',
358358
'genealabslaravelmodelcachingtestsfixturesbook',
@@ -362,7 +362,7 @@ public function testPluckModelResultsCreatesCache()
362362
$cachedResults = cache()->tags($tags)
363363
->get($key);
364364
$liveResults = (new UncachedAuthor)->with('books', 'profile')
365-
->pluck('id');
365+
->pluck('name', 'id');
366366

367367
$this->assertEmpty($authors->diffAssoc($cachedResults));
368368
$this->assertEmpty($liveResults->diffAssoc($cachedResults));

0 commit comments

Comments
 (0)