Completed
Push — master ( 3f89d7...f790e9 )
by Mike
30:28 queued 29:00
created

testBooleanWhereCreatesCorrectCacheKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder;
2
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author;
4
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor;
5
use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase;
6
7
class BooleanTest extends IntegrationTestCase
8
{
9
    public function testBooleanWhereCreatesCorrectCacheKey()
10
    {
11
        $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-is_famous_=_1-authors.deleted_at_null");
12
        $tags = [
13
            "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor",
14
        ];
15
16
        $authors = (new Author)
17
            ->where("is_famous", true)
18
            ->get();
19
        $cachedResults = $this->cache()
20
            ->tags($tags)
21
            ->get($key)['value'];
22
        $liveResults = (new UncachedAuthor)
23
            ->where("is_famous", true)
24
            ->get();
25
26
        $this->assertEquals($liveResults->pluck("id"), $authors->pluck("id"));
27
        $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id"));
28
        $this->assertNotEmpty($authors);
29
        $this->assertNotEmpty($cachedResults);
30
        $this->assertNotEmpty($liveResults);
31
    }
32
}
33