Commit 975f93e1 authored by Robert Lyon's avatar Robert Lyon
Browse files

Behat step to activate/deactivate a plugin



Change-Id: I6b0f495f0181fb6867211c6b7fb653fe41fdb64e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 9ce99623
......@@ -119,6 +119,73 @@ class BehatAdmin extends BehatBase {
}
/**
* Sets the specified plugin settings.
* A table with | Plugintype | Plugin | value | is expected.
*
* @Given /^the following plugins are set:$/
* @param TableNode $table
* @throws SystemException
*/
public function plugin_activation_set(TableNode $table) {
$settings = array();
foreach ($table->getHash() as $pluginsetting) {
$settings[$pluginsetting['plugintype']][$pluginsetting['plugin']] = $pluginsetting['value'];
}
// Validate the settings
$allowsettings = array(
'blocktype' => array (
'annotation',
'blog',
'comment',
),
'artefact' => array (
'blog',
'plans',
'resume',
),
'grouptype' => array(
'course',
),
'module' => array(
'smartevidence',
'lti',
'mobileapi',
),
);
// Update plugin settings
foreach ($settings as $plugintype => $plugins) {
if (!isset($allowsettings[$plugintype])) {
throw new SystemException("Not a valid plugintype \"$plugintype\"");
}
else {
foreach ($plugins as $plugin => $value) {
if (!in_array($plugin, $allowsettings[$plugintype])) {
throw new SystemException("\"$plugin\" is not a valid plugin for plugintype \"$plugintype\"");
}
else {
if ($plugintype == 'blocktype') {
// Don't enable blocktypes unless the artefact plugin that provides them is also enabled
$artefact = get_field('blocktype_installed', 'artefactplugin', 'name', $plugin);
if (!empty($value) && !empty($artefact)) {
set_field('artefact_installed', 'active', 1, 'name', $artefact);
}
}
else if ($plugintype == 'artefact' && empty($value)) {
// Disable all the artefact's blocktypes too
set_field('blocktype_installed', 'active', 0, 'artefactplugin', $plugin);
}
if (!set_field($plugintype . '_installed', 'active', $value, 'name', $plugin)) {
throw new SystemException("Can not activate / deactivate the \"$plugintype\" \"$plugin\"");
}
}
}
}
}
}
/**
* Sets the specified plugin settings.
* A table with | Plugintype | Plugin | Setting label | value | is expected.
......
@javascript @core @core_administration
Feature: Required plugins
In order to customise mahara we can turn off/on plugins
As an admin
I check that the plugins are activated/deactivated
Background:
Given the following plugins are set:
| plugintype | plugin | value |
| blocktype | annotation | 0 |
| artefact | plans | 0 |
Scenario: Checking that we can turn on/off plugins
Given I log in as "admin" with password "Kupuh1pa!"
And I choose "Plugin administration" in "Extensions" from administration menu
Then I should see "Show" in the "annotation/annotation" row
Then I should see "Show" in the "plans " row
Then I should see "Show" in the "plans/plans" row
Given the following plugins are set:
| plugintype | plugin | value |
| artefact | plans | 1 |
Then I should see "Hide" in the "plans " row
Then I should see "Hide" in the "plans/plans" row
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment