]>
git.agnieray.net Git - galette.git/blob - tests/Galette/Core/tests/units/Plugins.php
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 $method Method tested
96 public function beforeTestMethod($method)
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'];
110 * @param string $method Calling method
114 public function afterTestMethod($method)
116 if (TYPE_DB
=== 'mysql') {
117 $this->array($this->zdb
->getWarnings())->isIdenticalTo([]);
126 public function testLoadModules()
128 $plugins = $this->getPlugins();
130 $this->array($this->plugins
->getModules())
133 $loaded_plugin = $this->plugins
->getModules('plugin-test2');
134 $loaded_plugin['date'] = $this->plugin2
['date'];
136 $this->variable($loaded_plugin)
137 ->isIdenticalTo($this->plugin2
);
141 * Test module existence
145 public function testModuleExists()
147 $this->boolean($this->plugins
->moduleExists('plugin-test2'))
149 $this->boolean($this->plugins
->moduleExists('plugin-disabled'))
154 * Test disabled plugin
158 public function testDisabledModules()
160 $this->array($this->plugins
->getDisabledModules())
164 'plugin-unversionned',
175 public function testModuleRoot()
177 $this->variable($this->plugins
->moduleRoot('plugin-test2'))
178 ->isIdenticalTo($this->plugin2
['root']);
182 * Test templates path
186 /*public function testGetTemplatesPath()
189 // - at the moment, there is no config for preferences, so default theme is empty
190 // - remove global $preferences to have this one working as expected...
191 $this->variable($this->plugins->getTemplatesPath('plugin-test2'))
192 ->isIdenticalTo($this->plugin2['root'] . '/templates/');
196 * Test reset modules list
200 public function testResetModulesList()
202 $this->plugins
->resetModulesList();
204 $this->array($this->plugins
->getModules())
209 * Test plugin (des)activation
213 public function testModuleActivation()
215 $plugins = $this->getPlugins();
216 $this->array($plugins->getModules())
218 ->hasKey('plugin-test2');
219 $plugins->deactivateModule('plugin-test2');
221 $plugins = $this->getPlugins();
222 $this->array($plugins->getModules())
224 ->notHasKey('plugin-test2');
225 $plugins->activateModule('plugin-test2');
227 $plugins = $this->getPlugins();
228 $this->array($plugins->getModules())
230 ->hasKey('plugin-test2');
234 $plugins = $this->getPlugins();
235 $plugins->deactivateModule('nonexistant');
237 )->hasMessage(_T('No such module.'));
241 $plugins = $this->getPlugins();
242 $plugins->activateModule('nonexistant');
244 )->hasMessage(_T('No such module.'));
248 * Test if plugin needs database
252 public function testNeedDatabse()
254 $this->boolean($this->plugins
->needsDatabase('plugin-db'))
256 $this->boolean($this->plugins
->needsDatabase('plugin-test2'))
261 $plugins = $this->getPlugins();
262 $plugins->needsDatabase('nonexistant');
264 )->hasMessage(_T('Module does not exists!'));