diff options
-rw-r--r-- | plugins/default_colors/default_colors.php | 14 | ||||
-rw-r--r-- | tests/plugins/PluginDefaultColorsTest.php | 23 |
2 files changed, 37 insertions, 0 deletions
diff --git a/plugins/default_colors/default_colors.php b/plugins/default_colors/default_colors.php index 574a0bd4..d3e1fa76 100644 --- a/plugins/default_colors/default_colors.php +++ b/plugins/default_colors/default_colors.php | |||
@@ -47,6 +47,20 @@ function default_colors_init($conf) | |||
47 | } | 47 | } |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * When plugin parameters are saved, we regenerate the custom CSS file with provided settings. | ||
51 | * | ||
52 | * @param array $data $_POST array | ||
53 | * | ||
54 | * @return array Updated $_POST array | ||
55 | */ | ||
56 | function hook_default_colors_save_plugin_parameters($data) | ||
57 | { | ||
58 | default_colors_generate_css_file($data); | ||
59 | |||
60 | return $data; | ||
61 | } | ||
62 | |||
63 | /** | ||
50 | * When linklist is displayed, include default_colors CSS file. | 64 | * When linklist is displayed, include default_colors CSS file. |
51 | * | 65 | * |
52 | * @param array $data - header data. | 66 | * @param array $data - header data. |
diff --git a/tests/plugins/PluginDefaultColorsTest.php b/tests/plugins/PluginDefaultColorsTest.php index cc844c60..54e97612 100644 --- a/tests/plugins/PluginDefaultColorsTest.php +++ b/tests/plugins/PluginDefaultColorsTest.php | |||
@@ -193,4 +193,27 @@ class PluginDefaultColorsTest extends TestCase | |||
193 | $result = default_colors_format_css_rule($data, ''); | 193 | $result = default_colors_format_css_rule($data, ''); |
194 | $this->assertEmpty($result); | 194 | $this->assertEmpty($result); |
195 | } | 195 | } |
196 | |||
197 | /** | ||
198 | * Make sure that a new CSS file is generated when save_plugin_parameters hook is triggered. | ||
199 | */ | ||
200 | public function testHookSavePluginParameters(): void | ||
201 | { | ||
202 | $params = [ | ||
203 | 'other1' => true, | ||
204 | 'DEFAULT_COLORS_BACKGROUND' => 'pink', | ||
205 | 'other2' => ['yep'], | ||
206 | 'DEFAULT_COLORS_DARK_MAIN' => '', | ||
207 | ]; | ||
208 | |||
209 | hook_default_colors_save_plugin_parameters($params); | ||
210 | $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); | ||
211 | $content = file_get_contents($file); | ||
212 | $expected = ':root { | ||
213 | --background-color: pink; | ||
214 | |||
215 | } | ||
216 | '; | ||
217 | $this->assertEquals($expected, $content); | ||
218 | } | ||
196 | } | 219 | } |