Passed
Push — master ( 7af546...dfd36b )
by Arthur
04:54 queued 15s
created

BootstrappingTest::readContentsCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 03.10.18
6
 * Time: 22:58.
7
 */
8
9
namespace Foundation\Tests;
10
11
use Foundation\Services\BootstrapRegistrarService;
12
use Tests\TestCase;
13
14
class BootstrappingTest extends TestCase
15
{
16
    protected $service;
17
18
    public function __construct(?string $name = null, array $data = [], string $dataName = '')
19
    {
20
        parent::__construct($name, $data, $dataName);
21
        $this->service = new BootstrapRegistrarService();
22
    }
23
24
    public function testCacheDelete()
25
    {
26
        $this->assertTrue($this->service->cacheExists());
27
        $this->service->clearCache();
28
        $this->assertFalse($this->service->cacheExists());
29
    }
30
31
    public function testCaching()
32
    {
33
        if ($this->service->cacheExists()) {
34
            $this->service->clearCache();
35
        }
36
        $this->assertFalse($this->service->cacheExists());
37
        $this->service->recache();
38
        $this->assertTrue($this->service->cacheExists());
39
    }
40
41
    public function testReadContentsCache()
42
    {
43
        $bootstrapData = $this->service->loadBootstrapFromCache();
44
        $this->assertArrayHasKey('commands', $bootstrapData);
45
        $this->assertArrayHasKey('routes', $bootstrapData);
46
        $this->assertArrayHasKey('configs', $bootstrapData);
47
        $this->assertArrayHasKey('factories', $bootstrapData);
48
        $this->assertArrayHasKey('migrations', $bootstrapData);
49
        $this->assertArrayHasKey('seeders', $bootstrapData);
50
    }
51
52
    public function testBootstrapCacheCommand()
53
    {
54
        if ($this->service->cacheExists()) {
55
            $this->service->clearCache();
56
        }
57
        $this->assertFalse($this->service->cacheExists());
58
59
        \Artisan::call('bootstrap:cache');
60
61
        $this->assertTrue($this->service->cacheExists());
62
    }
63
}
64