X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fconfig%2FConfigPluginTest.php;h=3a45f623da7a8ff1b1750c8582084437034fae2b;hb=2b7a7bc928fb7fc171138e248d3aa1d86d5b62f9;hp=716631b0d54a87d000ed123361711dbeda32dbc2;hpb=0c4c7ae818336d5b0f94562e551ca1a3f34d3435;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/config/ConfigPluginTest.php b/tests/config/ConfigPluginTest.php index 716631b0..3a45f623 100644 --- a/tests/config/ConfigPluginTest.php +++ b/tests/config/ConfigPluginTest.php @@ -1,14 +1,15 @@ 2, // no plugin related 'plugin2' => 0, // new - at the end 'plugin3' => 0, // 2nd 'order_plugin3' => 8, 'plugin4' => 0, // 1st 'order_plugin4' => 5, - ); + ]; - $expected = array( + $expected = [ 'plugin3', 'plugin4', 'plugin2', - ); + ]; + + mkdir($path = __DIR__ . '/folder'); + PluginManager::$PLUGINS_PATH = $path; + array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, $expected); $out = save_plugin_config($data); $this->assertEquals($expected, $out); + + array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, $expected); + rmdir($path); } /** * Test save_plugin_config with invalid data. - * - * @expectedException PluginConfigOrderException */ public function testSavePluginConfigInvalid() { + $this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class); + $data = array( 'plugin2' => 0, 'plugin3' => 0, @@ -101,9 +109,9 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase $plugins = array( 'plugin_name' => array( 'parameters' => array( - 'param1' => true, - 'param2' => false, - 'param3' => '', + 'param1' => array('value' => true), + 'param2' => array('value' => false), + 'param3' => array('value' => ''), ) ) ); @@ -114,8 +122,8 @@ class ConfigPluginTest extends PHPUnit_Framework_TestCase ); $result = load_plugin_parameter_values($plugins, $parameters); - $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']); - $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']); - $this->assertEquals('', $result['plugin_name']['parameters']['param3']); + $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']); + $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']); + $this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']); } }