Passed
Push — master ( 67253e...1a1f73 )
by Arthur
04:53 queued 11s
created

CacheObserverTest::testClearSpecificModelCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Tests;
4
5
use Foundation\Abstracts\Tests\TestCase;
6
use Foundation\Cache\ModelCache;
7
use Modules\User\Entities\User;
8
9
class CacheObserverTest extends TestCase
10
{
11
12
    public function testCache()
13
    {
14
        $user = $this->createUser();
15
        $this->assertEquals($user, ModelCache::find($user->getKey(), User::class));
16
17
    }
18
19
    public function testClearModelsCache()
20
    {
21
        $user = $this->createUser();
22
23
        $this->assertNotNull(ModelCache::find($user->getKey(), User::class));
24
        ModelCache::clearAll();
25
        $this->assertEquals(null, ModelCache::findWithoutRequery($user->getKey(), User::class));
26
    }
27
28
    public function testClearSpecificModelCache()
29
    {
30
        $user = $this->createUser();
31
32
        $this->assertNotNull(ModelCache::find($user->getKey(), User::class));
33
        ModelCache::clearModel($user);
34
        $this->assertEquals(null, ModelCache::findWithoutRequery($user->getKey(), User::class));
35
    }
36
37
}
38