X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fplugins%2FPluginDefaultColorsTest.php;h=cc844c60f41e34edc0b61665e97c6f1227d6b3ac;hb=df25b28dcd3cde54d42c18a55a810daa82bf5727;hp=b9951cca6cb7ce68b4e4cc2024cdce999c6894d0;hpb=b5507350543f9259196996a24bbae2717b1b20be;p=github%2Fshaarli%2FShaarli.git 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 @@ namespace Shaarli\Plugin\DefaultColors; -use DateTime; -use PHPUnit\Framework\TestCase; use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; use Shaarli\Plugin\PluginManager; +use Shaarli\TestCase; require_once 'plugins/default_colors/default_colors.php'; @@ -20,7 +19,7 @@ class PluginDefaultColorsTest extends TestCase /** * Reset plugin path */ - public function setUp() + protected function setUp(): void { PluginManager::$PLUGINS_PATH = 'sandbox'; mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); @@ -33,7 +32,7 @@ class PluginDefaultColorsTest extends TestCase /** * Remove sandbox files and folder */ - public function tearDown() + protected function tearDown(): void { if (file_exists('sandbox/default_colors/default_colors.css.template')) { unlink('sandbox/default_colors/default_colors.css.template'); @@ -57,6 +56,8 @@ class PluginDefaultColorsTest extends TestCase $conf->set('plugins.DEFAULT_COLORS_BACKGROUND', 'value'); $errors = default_colors_init($conf); $this->assertEmpty($errors); + + $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); } /** @@ -72,9 +73,9 @@ class PluginDefaultColorsTest extends TestCase /** * Test the save plugin parameters hook with all colors specified. */ - public function testSavePluginParametersAll() + public function testGenerateCssFile() { - $post = [ + $params = [ 'other1' => true, 'DEFAULT_COLORS_MAIN' => 'blue', 'DEFAULT_COLORS_BACKGROUND' => 'pink', @@ -82,7 +83,7 @@ class PluginDefaultColorsTest extends TestCase 'DEFAULT_COLORS_DARK_MAIN' => 'green', ]; - hook_default_colors_save_plugin_parameters($post); + default_colors_generate_css_file($params); $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); $content = file_get_contents($file); $expected = ':root { @@ -98,16 +99,16 @@ class PluginDefaultColorsTest extends TestCase /** * Test the save plugin parameters hook with only one color specified. */ - public function testSavePluginParametersSingle() + public function testGenerateCssFileSingle() { - $post = [ + $params = [ 'other1' => true, 'DEFAULT_COLORS_BACKGROUND' => 'pink', 'other2' => ['yep'], 'DEFAULT_COLORS_DARK_MAIN' => '', ]; - hook_default_colors_save_plugin_parameters($post); + default_colors_generate_css_file($params); $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css'); $content = file_get_contents($file); $expected = ':root { @@ -121,9 +122,9 @@ class PluginDefaultColorsTest extends TestCase /** * Test the save plugin parameters hook with no color specified. */ - public function testSavePluginParametersNone() + public function testGenerateCssFileNone() { - hook_default_colors_save_plugin_parameters([]); + default_colors_generate_css_file([]); $this->assertFileNotExists($file = 'sandbox/default_colors/default_colors.css'); }