aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ConfigTest.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-01-31 19:00:13 +0100
committerArthur <arthur@hoa.ro>2016-01-31 19:00:13 +0100
commit53603f582300fc2709932b62652a5acfed088910 (patch)
tree9dbc383bf66cf9881a9b22d2437545740e26f7c1 /tests/ConfigTest.php
parent893338f0d407a0989454d5e3c0e43c97f7eface5 (diff)
parentdea0ba28f950867532eae572e7bcda49e81bbcf0 (diff)
downloadShaarli-53603f582300fc2709932b62652a5acfed088910.tar.gz
Shaarli-53603f582300fc2709932b62652a5acfed088910.tar.zst
Shaarli-53603f582300fc2709932b62652a5acfed088910.zip
Merge pull request #388 from ArthurHoaro/pluginadmin
Fixes #378 - Plugin administration UI.
Diffstat (limited to 'tests/ConfigTest.php')
-rw-r--r--tests/ConfigTest.php109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php
index adebfcc3..492ddd3b 100644
--- a/tests/ConfigTest.php
+++ b/tests/ConfigTest.php
@@ -174,4 +174,113 @@ class ConfigTest extends PHPUnit_Framework_TestCase
174 include self::$configFields['config']['CONFIG_FILE']; 174 include self::$configFields['config']['CONFIG_FILE'];
175 $this->assertEquals(self::$configFields['login'], $GLOBALS['login']); 175 $this->assertEquals(self::$configFields['login'], $GLOBALS['login']);
176 } 176 }
177
178 /**
179 * Test save_plugin_config with valid data.
180 *
181 * @throws PluginConfigOrderException
182 */
183 public function testSavePluginConfigValid()
184 {
185 $data = array(
186 'order_plugin1' => 2, // no plugin related
187 'plugin2' => 0, // new - at the end
188 'plugin3' => 0, // 2nd
189 'order_plugin3' => 8,
190 'plugin4' => 0, // 1st
191 'order_plugin4' => 5,
192 );
193
194 $expected = array(
195 'plugin3',
196 'plugin4',
197 'plugin2',
198 );
199
200 $out = save_plugin_config($data);
201 $this->assertEquals($expected, $out);
202 }
203
204 /**
205 * Test save_plugin_config with invalid data.
206 *
207 * @expectedException PluginConfigOrderException
208 */
209 public function testSavePluginConfigInvalid()
210 {
211 $data = array(
212 'plugin2' => 0,
213 'plugin3' => 0,
214 'order_plugin3' => 0,
215 'plugin4' => 0,
216 'order_plugin4' => 0,
217 );
218
219 save_plugin_config($data);
220 }
221
222 /**
223 * Test save_plugin_config without data.
224 */
225 public function testSavePluginConfigEmpty()
226 {
227 $this->assertEquals(array(), save_plugin_config(array()));
228 }
229
230 /**
231 * Test validate_plugin_order with valid data.
232 */
233 public function testValidatePluginOrderValid()
234 {
235 $data = array(
236 'order_plugin1' => 2,
237 'plugin2' => 0,
238 'plugin3' => 0,
239 'order_plugin3' => 1,
240 'plugin4' => 0,
241 'order_plugin4' => 5,
242 );
243
244 $this->assertTrue(validate_plugin_order($data));
245 }
246
247 /**
248 * Test validate_plugin_order with invalid data.
249 */
250 public function testValidatePluginOrderInvalid()
251 {
252 $data = array(
253 'order_plugin1' => 2,
254 'order_plugin3' => 1,
255 'order_plugin4' => 1,
256 );
257
258 $this->assertFalse(validate_plugin_order($data));
259 }
260
261 /**
262 * Test load_plugin_parameter_values.
263 */
264 public function testLoadPluginParameterValues()
265 {
266 $plugins = array(
267 'plugin_name' => array(
268 'parameters' => array(
269 'param1' => true,
270 'param2' => false,
271 'param3' => '',
272 )
273 )
274 );
275
276 $parameters = array(
277 'param1' => 'value1',
278 'param2' => 'value2',
279 );
280
281 $result = load_plugin_parameter_values($plugins, $parameters);
282 $this->assertEquals('value1', $result['plugin_name']['parameters']['param1']);
283 $this->assertEquals('value2', $result['plugin_name']['parameters']['param2']);
284 $this->assertEquals('', $result['plugin_name']['parameters']['param3']);
285 }
177} 286}