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

testFirstOrCreateFlushesCacheForModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder;
2
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author;
4
use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase;
5
6
class FirstOrCreateTest extends IntegrationTestCase
7
{
8
    public function testFirstOrCreateFlushesCacheForModel()
9
    {
10
        (new Author)->truncate();
11
12
        $items = [
13
            ['name' => 'foo', 'email' => '[email protected]'],
14
            ['name' => 'foo', 'email' => '[email protected]'],
15
            ['name' => 'foo', 'email' => '[email protected]'],
16
            ['name' => 'foo', 'email' => '[email protected]'],
17
            ['name' => 'foo', 'email' => '[email protected]'],
18
        ];
19
20
        foreach ($items as $item) {
21
            (new Author)->firstOrCreate($item);
22
        }
23
24
        $authors = (new Author)->get();
25
26
        $this->assertEquals(5, $authors->count());
27
    }
28
}
29