Completed
Push — master ( f02869...8251a6 )
by Nicolas
03:31
created

ThemeManagerTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A it_should_return_all_themes() 0 5 1
A it_should_return_a_theme() 0 7 1
A it_should_return_null_if_not_theme_found() 0 6 1
A it_should_return_empty_array_if_no_themes() 0 6 1
A it_should_return_empty_array_if_no_folder() 0 6 1
A getPath() 0 4 1
A getEmptyThemesPath() 0 4 1
A getFakePath() 0 4 1
1
<?php namespace Modules\Core\Tests\Theme;
2
3
use Modules\Core\Foundation\Theme\ThemeManager;
4
use Modules\Core\Tests\BaseTestCase;
5
6
class ThemeManagerTest extends BaseTestCase
7
{
8
    /**
9
     * @var \Modules\Core\Foundation\Theme\ThemeManager
10
     */
11
    protected $repository;
12
13
    /**
14
     *
15
     */
16
    public function setUp()
17
    {
18
        parent::setUp();
19
20
        $this->repository = new ThemeManager($this->app, $this->getPath());
21
    }
22
23
    /** @test */
24
    public function it_should_return_all_themes()
25
    {
26
        $this->assertTrue(is_array($this->repository->all()));
27
        $this->assertEquals($this->repository->count(), 2);
28
    }
29
30
    /** @test */
31
    public function it_should_return_a_theme()
32
    {
33
        $theme = $this->repository->find('demo');
34
35
        $this->assertInstanceOf('Modules\Core\Foundation\Theme\Theme', $theme);
36
        $this->assertEquals('demo', $theme->getLowerName());
37
    }
38
39
    /** @test */
40
    public function it_should_return_null_if_not_theme_found()
41
    {
42
        $theme = $this->repository->find('fakeTheme');
43
44
        $this->assertNull($theme);
45
    }
46
47
    /** @test */
48
    public function it_should_return_empty_array_if_no_themes()
49
    {
50
        $repository = new ThemeManager($this->app, $this->getEmptyThemesPath());
51
52
        $this->assertEquals([], $repository->all());
53
    }
54
55
    /** @test */
56
    public function it_should_return_empty_array_if_no_folder()
57
    {
58
        $repository = new ThemeManager($this->app, $this->getFakePath());
59
60
        $this->assertEquals([], $repository->all());
61
    }
62
63
    private function getPath()
64
    {
65
        return __DIR__ . '/Fixture/Themes';
66
    }
67
68
    private function getEmptyThemesPath()
69
    {
70
        return __DIR__ . '/Fixture/EmptyThemes';
71
    }
72
73
    private function getFakePath()
74
    {
75
        return __DIR__ . '/Fixture/fakeFolder';
76
    }
77
}
78