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

BootstrappingTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testBootstrapCacheCommand() 0 10 2
A __construct() 0 4 1
A testCacheDelete() 0 5 1
A testReadContentsCache() 0 9 1
A testCaching() 0 8 2
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