Passed
Push — master ( ed297f...604ea4 )
by Giuliano
04:39
created

UseThemeTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testUseExistingTheme() 0 11 1
A testUseInexistingTheme() 0 9 1
A getEnvKey() 0 5 1
A currentTheme() 0 7 1
1
<?php
2
3
namespace Maestriam\Samurai\Tests\Unit\Entities\Theme;
4
5
use Maestriam\Samurai\Entities\Theme;
6
use Maestriam\Samurai\Exceptions\ThemeNotFoundException;
7
use Maestriam\Samurai\Foundation\ConfigKeeper;
8
use Maestriam\Samurai\Foundation\EnvHandler;
9
10
class UseThemeTest extends ThemeTestCase
11
{
12
    public function testUseExistingTheme()
13
    {
14
        $name  = 'bands/accept';
15
        $theme = new Theme($name);
16
17
        $ret = $theme->make()->use();
18
19
        $current = $this->currentTheme();
20
21
        $this->assertValidTheme($ret);
22
        $this->assertEquals($current, $name);
23
    }
24
25
    public function testUseInexistingTheme()
26
    {
27
        $name = 'bands/accept';
28
        
29
        $theme = new Theme($name);
30
31
        $this->expectException(ThemeNotFoundException::class);
32
33
        $theme->use();
34
    }
35
    
36
    private function currentTheme() : string
37
    {
38
        $key = $this->getEnvKey();
39
40
        $env = new EnvHandler();
41
42
        return $env->get($key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $env->get($key) could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
        
45
    private function getEnvKey() : string
46
    {
47
        $config = new ConfigKeeper();
48
        
49
        return $config->env();
50
    }
51
}