mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-46210 langimport: behat tests
Behat tests for lang import. To run these tests you must define the TOOL_LANGIMPORT_REMOTE_TESTS constant - because they rely on the download.moodle.org infrastructure.
This commit is contained in:
parent
ed914e31c5
commit
49bee6dc67
3 changed files with 141 additions and 1 deletions
81
admin/tool/langimport/tests/behat/behat_tool_langimport.php
Normal file
81
admin/tool/langimport/tests/behat/behat_tool_langimport.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Behat steps definitions for Language import tool
|
||||
*
|
||||
* @package tool_langimport
|
||||
* @category test
|
||||
* @copyright 2014 Dan Poltawski <dan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
|
||||
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
|
||||
|
||||
use Moodle\BehatExtension\Exception\SkippedException;
|
||||
|
||||
/**
|
||||
* Steps definitions related with the Language import tool
|
||||
*
|
||||
* @package tool_langimport
|
||||
* @category test
|
||||
* @copyright 2014 Dan Poltawski <dan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_tool_langimport extends behat_base {
|
||||
|
||||
/**
|
||||
* This step looks to see if the remote language import tests should be run (indicated by
|
||||
* setting TOOL_LANGIMPORT_REMOTE_TESTS in config.php.
|
||||
*
|
||||
* @Given /^remote langimport tests are enabled$/
|
||||
*/
|
||||
public function remote_langimport_tests_are_enabled() {
|
||||
if (!defined('TOOL_LANGIMPORT_REMOTE_TESTS')) {
|
||||
throw new SkippedException('To run the remote langimport tests you must '.
|
||||
'define TOOL_LANGIMPORT_REMOTE_TESTS in config.php');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a langpack and fakes it being outdated
|
||||
*
|
||||
* @param string $langcode The language code (e.g. en)
|
||||
* @Given /^outdated langpack \'([^\']*)\' is installed$/
|
||||
*/
|
||||
public function outdated_langpack_is_installed($langcode) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
// Download the langpack.
|
||||
$dir = make_upload_directory('lang');
|
||||
$installer = new lang_installer($langcode);
|
||||
$result = $installer->run();
|
||||
|
||||
if ($result[$langcode] !== lang_installer::RESULT_INSTALLED) {
|
||||
throw new coding_exception("Failed to install langpack '$langcode'");
|
||||
}
|
||||
|
||||
$path = "$dir/$langcode/$langcode.md5";
|
||||
|
||||
if (!file_exists($path)) {
|
||||
throw new coding_exception("Failed to find '$langcode' checksum");
|
||||
}
|
||||
file_put_contents($path, '000000');
|
||||
}
|
||||
}
|
59
admin/tool/langimport/tests/behat/manage_langpacks.feature
Normal file
59
admin/tool/langimport/tests/behat/manage_langpacks.feature
Normal file
|
@ -0,0 +1,59 @@
|
|||
@tool @tool_langimport
|
||||
Feature: Manage language packs
|
||||
In order to support different languages
|
||||
As an administrator
|
||||
I need to be able to add, update and remove language packs
|
||||
|
||||
|
||||
Background:
|
||||
Given remote langimport tests are enabled
|
||||
|
||||
# The pirate language pack is used for testing because its small to download.
|
||||
|
||||
Scenario: Install language pack
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language packs" node in "Site administration > Language"
|
||||
When I set the field "Available language packs" to "English - Pirate (en_ar)"
|
||||
And I press "Install selected language pack(s)"
|
||||
Then I should see "Language pack 'en_ar' was successfully installed"
|
||||
And the "Installed language packs" select box should contain "English - Pirate (en_ar)"
|
||||
And I navigate to "Live logs" node in "Site administration > Reports"
|
||||
And I should see "The language pack 'en_ar' was installed."
|
||||
And I log out
|
||||
|
||||
Scenario: Update language pack
|
||||
Given outdated langpack 'en_ar' is installed
|
||||
And I log in as "admin"
|
||||
And I navigate to "Language packs" node in "Site administration > Language"
|
||||
When I press "Update all installed language packs"
|
||||
Then I should see "Language pack 'en_ar' was successfully updated"
|
||||
And I should see "Language pack update completed"
|
||||
And I navigate to "Live logs" node in "Site administration > Reports"
|
||||
And I should see "The language pack 'en_ar' was updated."
|
||||
And I log out
|
||||
|
||||
Scenario: Try to uninstall language pack
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language packs" node in "Site administration > Language"
|
||||
And I set the field "Available language packs" to "English - Pirate (en_ar)"
|
||||
And I press "Install selected language pack(s)"
|
||||
When I set the field "Installed language packs" to "English - Pirate (en_ar)"
|
||||
And I press "Uninstall selected language pack"
|
||||
And I press "Continue"
|
||||
Then I should see "Language pack 'en_ar' was uninstalled"
|
||||
And the "Installed language packs" select box should not contain "English - Pirate (en_ar)"
|
||||
And the "Available language packs" select box should contain "English - Pirate (en_ar)"
|
||||
And I navigate to "Live logs" node in "Site administration > Reports"
|
||||
And I should see "The language pack 'en_ar' was removed."
|
||||
And I should see "Language pack uninstalled"
|
||||
And I log out
|
||||
|
||||
Scenario: Try to uninstall English language pack
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Language packs" node in "Site administration > Language"
|
||||
When I set the field "Installed language packs" to "English (en)"
|
||||
And I press "Uninstall selected language pack"
|
||||
Then I should see "English language pack can not be uninstalled"
|
||||
And I navigate to "Live logs" node in "Site administration > Reports"
|
||||
And I should not see "Language pack uninstalled"
|
||||
And I log out
|
|
@ -25,6 +25,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014092800; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2014092801; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2014050800; // Requires this Moodle version
|
||||
$plugin->component = 'tool_langimport'; // Full name of the plugin (used for diagnostics)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue