diff options
author | Arthur <arthur@hoa.ro> | 2017-01-06 11:40:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 11:40:54 +0100 |
commit | 7418f7cb60524c3bfc2f240386b5e3e7eb9b3257 (patch) | |
tree | 4b0c89c133ad1679c5db3a4f0f6b94079f776395 /tests/ThemeUtilsTest.php | |
parent | 93b1fe54fb99efff30eec0d405cc7319fbbc1f95 (diff) | |
parent | 01c6e32a02034ab119d83364c4648ce55d75543b (diff) | |
download | Shaarli-7418f7cb60524c3bfc2f240386b5e3e7eb9b3257.tar.gz Shaarli-7418f7cb60524c3bfc2f240386b5e3e7eb9b3257.tar.zst Shaarli-7418f7cb60524c3bfc2f240386b5e3e7eb9b3257.zip |
Merge pull request #732 from ArthurHoaro/feature/theme-manager
Theme manager: improvements
Diffstat (limited to 'tests/ThemeUtilsTest.php')
-rw-r--r-- | tests/ThemeUtilsTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/ThemeUtilsTest.php b/tests/ThemeUtilsTest.php new file mode 100644 index 00000000..e44564be --- /dev/null +++ b/tests/ThemeUtilsTest.php | |||
@@ -0,0 +1,55 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Shaarli; | ||
4 | |||
5 | /** | ||
6 | * Class ThemeUtilsTest | ||
7 | * | ||
8 | * @package Shaarli | ||
9 | */ | ||
10 | class ThemeUtilsTest extends \PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | /** | ||
13 | * Test getThemes() with existing theme directories. | ||
14 | */ | ||
15 | public function testGetThemes() | ||
16 | { | ||
17 | $themes = ['theme1', 'default', 'Bl1p_- bL0p']; | ||
18 | foreach ($themes as $theme) { | ||
19 | mkdir('sandbox/tpl/'. $theme, 0755, true); | ||
20 | } | ||
21 | |||
22 | // include a file which should be ignored | ||
23 | touch('sandbox/tpl/supertheme'); | ||
24 | |||
25 | $res = ThemeUtils::getThemes('sandbox/tpl/'); | ||
26 | foreach ($res as $theme) { | ||
27 | $this->assertTrue(in_array($theme, $themes)); | ||
28 | } | ||
29 | $this->assertFalse(in_array('supertheme', $res)); | ||
30 | |||
31 | foreach ($themes as $theme) { | ||
32 | rmdir('sandbox/tpl/'. $theme); | ||
33 | } | ||
34 | unlink('sandbox/tpl/supertheme'); | ||
35 | rmdir('sandbox/tpl'); | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * Test getThemes() without any theme dir. | ||
40 | */ | ||
41 | public function testGetThemesEmpty() | ||
42 | { | ||
43 | mkdir('sandbox/tpl/', 0755, true); | ||
44 | $this->assertEquals([], ThemeUtils::getThemes('sandbox/tpl/')); | ||
45 | rmdir('sandbox/tpl/'); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * Test getThemes() with an invalid path. | ||
50 | */ | ||
51 | public function testGetThemesInvalid() | ||
52 | { | ||
53 | $this->assertEquals([], ThemeUtils::getThemes('nope')); | ||
54 | } | ||
55 | } | ||