diff options
Diffstat (limited to 'tests/plugins/PluginDefaultColorsTest.php')
-rw-r--r-- | tests/plugins/PluginDefaultColorsTest.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/plugins/PluginDefaultColorsTest.php b/tests/plugins/PluginDefaultColorsTest.php index b9951cca..cc844c60 100644 --- a/tests/plugins/PluginDefaultColorsTest.php +++ b/tests/plugins/PluginDefaultColorsTest.php | |||
@@ -2,11 +2,10 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Plugin\DefaultColors; | 3 | namespace Shaarli\Plugin\DefaultColors; |
4 | 4 | ||
5 | use DateTime; | ||
6 | use PHPUnit\Framework\TestCase; | ||
7 | use Shaarli\Bookmark\LinkDB; | 5 | use Shaarli\Bookmark\LinkDB; |
8 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
9 | use Shaarli\Plugin\PluginManager; | 7 | use Shaarli\Plugin\PluginManager; |
8 | use Shaarli\TestCase; | ||
10 | 9 | ||
11 | require_once 'plugins/default_colors/default_colors.php'; | 10 | require_once 'plugins/default_colors/default_colors.php'; |
12 | 11 | ||
@@ -20,7 +19,7 @@ class PluginDefaultColorsTest extends TestCase | |||
20 | /** | 19 | /** |
21 | * Reset plugin path | 20 | * Reset plugin path |
22 | */ | 21 | */ |
23 | public function setUp() | 22 | protected function setUp(): void |
24 | { | 23 | { |
25 | PluginManager::$PLUGINS_PATH = 'sandbox'; | 24 | PluginManager::$PLUGINS_PATH = 'sandbox'; |
26 | mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); | 25 | mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); |
@@ -33,7 +32,7 @@ class PluginDefaultColorsTest extends TestCase | |||
33 | /** | 32 | /** |
34 | * Remove sandbox files and folder | 33 | * Remove sandbox files and folder |
35 | */ | 34 | */ |
36 | public function tearDown() | 35 | protected function tearDown(): void |
37 | { | 36 | { |
38 | if (file_exists('sandbox/default_colors/default_colors.css.template')) { | 37 | if (file_exists('sandbox/default_colors/default_colors.css.template')) { |
39 | unlink('sandbox/default_colors/default_colors.css.template'); | 38 | unlink('sandbox/default_colors/default_colors.css.template'); |
@@ -57,6 +56,8 @@ class PluginDefaultColorsTest extends TestCase | |||
57 | $conf->set('plugins.DEFAULT_COLORS_BACKGROUND', 'value'); | 56 | $conf->set('plugins.DEFAULT_COLORS_BACKGROUND', 'value'); |
58 | $errors = default_colors_init($conf); | 57 | $errors = default_colors_init($conf); |
59 | $this->assertEmpty($errors); | 58 | $this->assertEmpty($errors); |
59 | |||
60 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | /** | 63 | /** |
@@ -72,9 +73,9 @@ class PluginDefaultColorsTest extends TestCase | |||
72 | /** | 73 | /** |
73 | * Test the save plugin parameters hook with all colors specified. | 74 | * Test the save plugin parameters hook with all colors specified. |
74 | */ | 75 | */ |
75 | public function testSavePluginParametersAll() | 76 | public function testGenerateCssFile() |
76 | { | 77 | { |
77 | $post = [ | 78 | $params = [ |
78 | 'other1' => true, | 79 | 'other1' => true, |
79 | 'DEFAULT_COLORS_MAIN' => 'blue', | 80 | 'DEFAULT_COLORS_MAIN' => 'blue', |
80 | 'DEFAULT_COLORS_BACKGROUND' => 'pink', | 81 | 'DEFAULT_COLORS_BACKGROUND' => 'pink', |
@@ -82,7 +83,7 @@ class PluginDefaultColorsTest extends TestCase | |||
82 | 'DEFAULT_COLORS_DARK_MAIN' => 'green', | 83 | 'DEFAULT_COLORS_DARK_MAIN' => 'green', |
83 | ]; | 84 | ]; |
84 | 85 | ||
85 | hook_default_colors_save_plugin_parameters($post); | 86 | default_colors_generate_css_file($params); |
86 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); | 87 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); |
87 | $content = file_get_contents($file); | 88 | $content = file_get_contents($file); |
88 | $expected = ':root { | 89 | $expected = ':root { |
@@ -98,16 +99,16 @@ class PluginDefaultColorsTest extends TestCase | |||
98 | /** | 99 | /** |
99 | * Test the save plugin parameters hook with only one color specified. | 100 | * Test the save plugin parameters hook with only one color specified. |
100 | */ | 101 | */ |
101 | public function testSavePluginParametersSingle() | 102 | public function testGenerateCssFileSingle() |
102 | { | 103 | { |
103 | $post = [ | 104 | $params = [ |
104 | 'other1' => true, | 105 | 'other1' => true, |
105 | 'DEFAULT_COLORS_BACKGROUND' => 'pink', | 106 | 'DEFAULT_COLORS_BACKGROUND' => 'pink', |
106 | 'other2' => ['yep'], | 107 | 'other2' => ['yep'], |
107 | 'DEFAULT_COLORS_DARK_MAIN' => '', | 108 | 'DEFAULT_COLORS_DARK_MAIN' => '', |
108 | ]; | 109 | ]; |
109 | 110 | ||
110 | hook_default_colors_save_plugin_parameters($post); | 111 | default_colors_generate_css_file($params); |
111 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); | 112 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); |
112 | $content = file_get_contents($file); | 113 | $content = file_get_contents($file); |
113 | $expected = ':root { | 114 | $expected = ':root { |
@@ -121,9 +122,9 @@ class PluginDefaultColorsTest extends TestCase | |||
121 | /** | 122 | /** |
122 | * Test the save plugin parameters hook with no color specified. | 123 | * Test the save plugin parameters hook with no color specified. |
123 | */ | 124 | */ |
124 | public function testSavePluginParametersNone() | 125 | public function testGenerateCssFileNone() |
125 | { | 126 | { |
126 | hook_default_colors_save_plugin_parameters([]); | 127 | default_colors_generate_css_file([]); |
127 | $this->assertFileNotExists($file = 'sandbox/default_colors/default_colors.css'); | 128 | $this->assertFileNotExists($file = 'sandbox/default_colors/default_colors.css'); |
128 | } | 129 | } |
129 | 130 | ||