|
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
|
|
|
|