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

UpdateTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

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