Completed
Push — master ( ef62ef...3339ef )
by Mike
02:44
created

CacheTest::testCacheIsNotEmptyAfterLoadingModels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Unit;
2
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author;
4
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book;
5
use GeneaLabs\LaravelModelCaching\Tests\TestCase;
6
use Illuminate\Foundation\Testing\RefreshDatabase;
7
8
class CacheTest extends TestCase
9
{
10
    use RefreshDatabase;
11
12
    public function setUp()
13
    {
14
        parent::setUp();
15
16
        factory(Author::class, 10)->create()
17
            ->each(function($author) {
18
                factory(Book::class, random_int(2, 10))->make()
19
                    ->each(function ($book) use ($author) {
20
                        $book->author()->associate($author);
21
                        $book->save();
22
                    });
23
            });
24
    }
25
26
    public function testCacheIsEmptyBeforeLoadingModels()
27
    {
28
        $this->assertNull(cache()->get('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks'));
29
    }
30
31
    public function testCacheIsNotEmptyAfterLoadingModels()
32
    {
33
        (new Author)->with('books')->get();
34
35
        $this->assertNotNull(cache()->get('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks'));
36
    }
37
}
38