X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Ffront%2Fcontroller%2Fadmin%2FPluginsControllerTest.php;h=9526474c906e454d6c9672c2e61c8294a7a61326;hb=4af591ff3c5db4dea5b6c437527f6f9b12917570;hp=700a0df2670939f3e8f364cd1711e01fd0dfaa6d;hpb=1b8620b1ad4e2c647ff2d032c8e7c6687b6647a1;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/front/controller/admin/PluginsControllerTest.php b/tests/front/controller/admin/PluginsControllerTest.php index 700a0df2..9526474c 100644 --- a/tests/front/controller/admin/PluginsControllerTest.php +++ b/tests/front/controller/admin/PluginsControllerTest.php @@ -7,6 +7,7 @@ namespace Shaarli\Front\Controller\Admin; 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; @@ -15,6 +16,8 @@ class PluginsControllerTest extends TestCase { use FrontAdminControllerMockHelper; + const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4']; + /** @var PluginsController */ protected $controller; @@ -23,6 +26,17 @@ class PluginsControllerTest extends TestCase $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); } /** @@ -111,6 +125,7 @@ class PluginsControllerTest extends TestCase 'parameters_form' => true, 'parameter1' => 'blip', 'parameter2' => 'blop', + 'token' => 'this parameter should not be saved' ]; $request = $this->createMock(Request::class); @@ -129,7 +144,7 @@ class PluginsControllerTest extends TestCase ->with('save_plugin_parameters', $parameters) ; $this->container->conf - ->expects(static::atLeastOnce()) + ->expects(static::exactly(2)) ->method('set') ->withConsecutive(['plugins.parameter1', 'blip'], ['plugins.parameter2', 'blop']) ; @@ -162,7 +177,7 @@ class PluginsControllerTest extends TestCase ->method('setSessionParameter') ->with( SessionManager::KEY_ERROR_MESSAGES, - ['ERROR while saving plugin configuration: ' . PHP_EOL . $message] + ['Error while saving plugin configuration: ' . PHP_EOL . $message] ) ;