]>
git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/Plugins.php
93adda18c22bac7406d497e7758a0ed771506928
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2013-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
28 * @package GaletteTests
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
38 namespace Galette\Core\test\units
;
47 * @package GaletteTests
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2013-2014 The Galette Team
50 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
51 * @link http://galette.tuxfamily.org
54 class Plugins
extends atoum
60 private $plugin2 = array(
61 'root' => 'plugin-test2',
62 'name' => 'Galette Test2 Plugin',
63 'desc' => 'Test two plugin',
64 'author' => 'Johan Cwiklinski',
67 'plugin2_root' => 'member',
68 'plugin2_admin' => 'staff'
70 'date' => '2013-12-15',
72 'root_writable' => true,
77 * Get instanciated plugins instance
79 * @return Galette\Core\Plugins
81 private function getPlugins()
83 $plugins = new \Galette\Core\
Plugins();
84 $plugins->autoload(GALETTE_PLUGINS_PATH
);
85 $plugins->loadModules($this->preferences
, GALETTE_PLUGINS_PATH
);
92 * @param string $testMethod Method tested
96 public function beforeTestMethod($testMethod)
98 $this->zdb
= new \Galette\Core\
Db();
99 $this->preferences
= new \Galette\Core\
Preferences($this->zdb
);
101 $this->plugins
= $this->getPlugins();
103 $this->plugin2
['root'] = GALETTE_PLUGINS_PATH
.
104 $this->plugin2
['root'];
113 public function testLoadModules()
115 $plugins = $this->getPlugins();
117 $this->array($this->plugins
->getModules())
120 $loaded_plugin = $this->plugins
->getModules('plugin-test2');
121 $loaded_plugin['date'] = $this->plugin2
['date'];
123 $this->variable($loaded_plugin)
124 ->isIdenticalTo($this->plugin2
);
128 * Test module existence
132 public function testModuleExists()
134 $this->boolean($this->plugins
->moduleExists('plugin-test2'))
136 $this->boolean($this->plugins
->moduleExists('plugin-disabled'))
141 * Test disabled plugin
145 public function testDisabledModules()
147 $this->array($this->plugins
->getDisabledModules())
151 'plugin-unversionned',
162 public function testModuleRoot()
164 $this->variable($this->plugins
->moduleRoot('plugin-test2'))
165 ->isIdenticalTo($this->plugin2
['root']);
169 * Test templates path
173 /*public function testGetTemplatesPath()
176 // - at the moment, there is no config for preferences, so default theme is empty
177 // - remove global $preferences to have this one working as expected...
178 $this->variable($this->plugins->getTemplatesPath('plugin-test2'))
179 ->isIdenticalTo($this->plugin2['root'] . '/templates/');
183 * Test reset modules list
187 public function testResetModulesList()
189 $this->plugins
->resetModulesList();
191 $this->array($this->plugins
->getModules())
196 * Test plugin (des)activation
200 public function testModuleActivation()
202 $plugins = $this->getPlugins();
203 $this->array($plugins->getModules())
205 ->hasKey('plugin-test2');
206 $plugins->deactivateModule('plugin-test2');
208 $plugins = $this->getPlugins();
209 $this->array($plugins->getModules())
211 ->notHasKey('plugin-test2');
212 $plugins->activateModule('plugin-test2');
214 $plugins = $this->getPlugins();
215 $this->array($plugins->getModules())
217 ->hasKey('plugin-test2');
221 $plugins = $this->getPlugins();
222 $plugins->deactivateModule('nonexistant');
224 )->hasMessage(_T('No such module.'));
228 $plugins = $this->getPlugins();
229 $plugins->activateModule('nonexistant');
231 )->hasMessage(_T('No such module.'));
235 * Test if plugin needs database
239 public function testNeedDatabse()
241 $this->boolean($this->plugins
->needsDatabase('plugin-db'))
243 $this->boolean($this->plugins
->needsDatabase('plugin-test2'))
248 $plugins = $this->getPlugins();
249 $plugins->needsDatabase('nonexistant');
251 )->hasMessage(_T('Module does not exists!'));