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

BooleanTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 26
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBooleanWhereCreatesCorrectCacheKey() 0 23 1
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