Completed
Pull Request — master (#372)
by Mike
31:01 queued 16:07
created

UpdateTest::testUpdateFlushesCacheForModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Feature\Nova;
2
3
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author;
4
use GeneaLabs\LaravelModelCaching\Tests\NovaTestCase;
5
6
class UpdateTest extends NovaTestCase
7
{
8
    public function testUpdateFlushesCacheForModel()
9
    {
10
        $beforeAuthors = (new Author)->get();
11
        $author = $beforeAuthors->first();
12
13
        $this->putJson('nova-api/authors/' . $author->id, [
14
            'name' => 'foo',
15
            'email' => '[email protected]',
16
        ]);
17
18
        $authors = (new Author)->get();
19
20
        $this->response->assertStatus(200);
21
        $this->assertCount(10, $beforeAuthors);
22
        $this->assertCount(10, $authors);
23
24
        $updatedAuthor = $authors->first();
25
        $this->assertTrue($updatedAuthor->is($author));
26
        $this->assertSame('foo', $updatedAuthor->name);
27
        $this->assertSame('[email protected]', $updatedAuthor->email);
28
29
        $author->refresh();
30
        $this->assertSame('foo', $author->name);
31
        $this->assertSame('[email protected]', $author->email);
32
    }
33
}
34