use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager;
use Shaarli\Front\Exception\WrongTokenException;
+use Shaarli\Plugin\PluginManager;
use Shaarli\Security\SessionManager;
use Slim\Http\Request;
use Slim\Http\Response;
{
use FrontAdminControllerMockHelper;
+ const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4'];
+
/** @var PluginsController */
protected $controller;
$this->createContainer();
$this->controller = new PluginsController($this->container);
+
+ mkdir($path = __DIR__ . '/folder');
+ PluginManager::$PLUGINS_PATH = $path;
+ array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES);
+ }
+
+ public function tearDown(): void
+ {
+ $path = __DIR__ . '/folder';
+ array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES);
+ rmdir($path);
}
/**
'parameters_form' => true,
'parameter1' => 'blip',
'parameter2' => 'blop',
+ 'token' => 'this parameter should not be saved'
];
$request = $this->createMock(Request::class);
->with('save_plugin_parameters', $parameters)
;
$this->container->conf
- ->expects(static::atLeastOnce())
+ ->expects(static::exactly(2))
->method('set')
->withConsecutive(['plugins.parameter1', 'blip'], ['plugins.parameter2', 'blop'])
;
->method('setSessionParameter')
->with(
SessionManager::KEY_ERROR_MESSAGES,
- ['ERROR while saving plugin configuration: ' . PHP_EOL . $message]
+ ['Error while saving plugin configuration: ' . PHP_EOL . $message]
)
;