2 namespace Shaarli\Config
;
4 use Shaarli\Config\Exception\PluginConfigOrderException
;
6 require_once 'application/config/ConfigPlugin.php';
9 * Unitary tests for Shaarli config related functions
11 class ConfigPluginTest
extends \PHPUnit_Framework_TestCase
14 * Test save_plugin_config with valid data.
16 * @throws PluginConfigOrderException
18 public function testSavePluginConfigValid()
21 'order_plugin1' => 2, // no plugin related
22 'plugin2' => 0, // new - at the end
23 'plugin3' => 0, // 2nd
25 'plugin4' => 0, // 1st
35 $out = save_plugin_config($data);
36 $this->assertEquals($expected, $out);
40 * Test save_plugin_config with invalid data.
42 * @expectedException Shaarli\Config\Exception\PluginConfigOrderException
44 public function testSavePluginConfigInvalid()
54 save_plugin_config($data);
58 * Test save_plugin_config without data.
60 public function testSavePluginConfigEmpty()
62 $this->assertEquals(array(), save_plugin_config(array()));
66 * Test validate_plugin_order with valid data.
68 public function testValidatePluginOrderValid()
79 $this->assertTrue(validate_plugin_order($data));
83 * Test validate_plugin_order with invalid data.
85 public function testValidatePluginOrderInvalid()
93 $this->assertFalse(validate_plugin_order($data));
97 * Test load_plugin_parameter_values.
99 public function testLoadPluginParameterValues()
102 'plugin_name' => array(
103 'parameters' => array(
104 'param1' => array('value' => true),
105 'param2' => array('value' => false),
106 'param3' => array('value' => ''),
112 'param1' => 'value1',
113 'param2' => 'value2',
116 $result = load_plugin_parameter_values($plugins, $parameters);
117 $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
118 $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']['value']);
119 $this->assertEquals('', $result['plugin_name']['parameters']['param3']['value']);