diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-29 09:38:30 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-08-29 09:38:30 +0200 |
commit | 972daa4513420d3293d46a808ca2d5be0313e78b (patch) | |
tree | aeafedfe73e020c3e798aebd7fd84e536e87c8c7 /tests | |
parent | bea062149ebcb4663861edb1cc0a32faf85b273f (diff) | |
download | Shaarli-972daa4513420d3293d46a808ca2d5be0313e78b.tar.gz Shaarli-972daa4513420d3293d46a808ca2d5be0313e78b.tar.zst Shaarli-972daa4513420d3293d46a808ca2d5be0313e78b.zip |
Default colors plugin: generate CSS file during initialization
Current behaviour only generate the custom CSS file when the plugin settings are saved, which can be annoying if the file is deleted but the settings are set.
Most common use case is Docker deployment, because the plugin directory is not mounted as a volume.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/PluginDefaultColorsTest.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/plugins/PluginDefaultColorsTest.php b/tests/plugins/PluginDefaultColorsTest.php index b9951cca..9835dfa3 100644 --- a/tests/plugins/PluginDefaultColorsTest.php +++ b/tests/plugins/PluginDefaultColorsTest.php | |||
@@ -2,7 +2,6 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Plugin\DefaultColors; | 3 | namespace Shaarli\Plugin\DefaultColors; |
4 | 4 | ||
5 | use DateTime; | ||
6 | use PHPUnit\Framework\TestCase; | 5 | use PHPUnit\Framework\TestCase; |
7 | use Shaarli\Bookmark\LinkDB; | 6 | use Shaarli\Bookmark\LinkDB; |
8 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
@@ -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 | ||