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';
/**
* Reset plugin path
*/
- public function setUp()
+ protected function setUp(): void
{
PluginManager::$PLUGINS_PATH = 'sandbox';
mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/');
/**
* 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');
$conf->set('plugins.DEFAULT_COLORS_BACKGROUND', 'value');
$errors = default_colors_init($conf);
$this->assertEmpty($errors);
+
+ $this->assertFileExists($file = 'sandbox/default_colors/default_colors.css');
}
/**
/**
* 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',
'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 {
/**
* 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 {
/**
* 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');
}