mirror of
https://github.com/moodle/moodle.git
synced 2025-02-25 20:43:33 +01:00
MDL-82424 tool_generator: plugin handling on test scenarios
This commit is contained in:
parent
a3e810bf7e
commit
5cd11ee33a
@ -20,6 +20,7 @@ use behat_admin;
|
||||
use behat_data_generators;
|
||||
use behat_base;
|
||||
use behat_course;
|
||||
use behat_general;
|
||||
use behat_user;
|
||||
use Behat\Gherkin\Parser;
|
||||
use Behat\Gherkin\Lexer;
|
||||
@ -82,6 +83,7 @@ class runner {
|
||||
require_once("{$CFG->dirroot}/admin/tests/behat/behat_admin.php");
|
||||
require_once("{$CFG->dirroot}/course/lib.php");
|
||||
require_once("{$CFG->dirroot}/course/tests/behat/behat_course.php");
|
||||
require_once("{$CFG->dirroot}/lib/tests/behat/behat_general.php");
|
||||
require_once("{$CFG->dirroot}/user/tests/behat/behat_user.php");
|
||||
return true;
|
||||
}
|
||||
@ -93,13 +95,22 @@ class runner {
|
||||
$this->generator = new behat_data_generators();
|
||||
$this->validsteps = $this->scan_generator($this->generator);
|
||||
|
||||
// Set config values is not inside the general behat generators.
|
||||
$extra = $this->scan_method(
|
||||
new ReflectionMethod(behat_admin::class, 'the_following_config_values_are_set_as_admin'),
|
||||
new behat_admin(),
|
||||
);
|
||||
if ($extra) {
|
||||
$this->validsteps[$extra->given] = $extra;
|
||||
// Add some extra steps from other classes.
|
||||
$extrasteps = [
|
||||
[behat_admin::class, 'the_following_config_values_are_set_as_admin'],
|
||||
[behat_general::class, 'i_enable_plugin'],
|
||||
[behat_general::class, 'i_disable_plugin'],
|
||||
];
|
||||
foreach ($extrasteps as $callable) {
|
||||
$classname = $callable[0];
|
||||
$method = $callable[1];
|
||||
$extra = $this->scan_method(
|
||||
new ReflectionMethod($classname, $method),
|
||||
new $classname(),
|
||||
);
|
||||
if ($extra) {
|
||||
$this->validsteps[$extra->given] = $extra;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,10 @@ class steprunner {
|
||||
if (isset($matches[$paramname])) {
|
||||
$params[] = $matches[$paramname];
|
||||
unset($matches[$paramname]);
|
||||
} else if (isset($matches["{$paramname}_string"])) {
|
||||
// If the param uses a regular expression with a name.
|
||||
$params[] = $matches["{$paramname}_string"];
|
||||
unset($matches["{$paramname}_string"]);
|
||||
} else if (count($matches) > 0) {
|
||||
// If the param is not present means the regular expressions does not use
|
||||
// proper names. So we will try to find the param by position.
|
||||
|
18
admin/tool/generator/tests/behat/testscenario_steps.feature
Normal file
18
admin/tool/generator/tests/behat/testscenario_steps.feature
Normal file
@ -0,0 +1,18 @@
|
||||
@tool @tool_generator @_file_upload
|
||||
Feature: Make test scenario can execute specific steps
|
||||
In order to create all sort of testing scenarios
|
||||
As a developer
|
||||
I need to execute some generic steps in the current instance
|
||||
|
||||
@javascript
|
||||
Scenario: Make test scenario can enable and disable plugins
|
||||
Given I disable "page" "mod" plugin
|
||||
And I log in as "admin"
|
||||
And I navigate to "Development > Create testing scenarios" in site administration
|
||||
And I upload "admin/tool/generator/tests/fixtures/testscenario/scenario_plugins.feature" file to "Feature file" filemanager
|
||||
And I press "Import"
|
||||
And I should see "Scenario: Course with some disabled plugins"
|
||||
When I am on "C1" course homepage with editing mode on
|
||||
And I click on "Add an activity or resource" "button" in the "Section 1" "section"
|
||||
Then I should see "Page" in the "Add an activity or resource" "dialogue"
|
||||
And I should not see "Book" in the "Add an activity or resource" "dialogue"
|
12
admin/tool/generator/tests/fixtures/testscenario/scenario_plugins.feature
vendored
Normal file
12
admin/tool/generator/tests/fixtures/testscenario/scenario_plugins.feature
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
Feature: Enable and disable plugins
|
||||
Scenario: Course with some disabled plugins
|
||||
Given the following config values are set as admin:
|
||||
| sendcoursewelcomemessage | 0 | enrol_manual |
|
||||
And I enable "page" "mod" plugin
|
||||
And I disable "book" "mod" plugin
|
||||
And the following "course" exists:
|
||||
| fullname | Course test |
|
||||
| shortname | C1 |
|
||||
| category | 0 |
|
||||
| numsections | 3 |
|
||||
| initsections | 1 |
|
Loading…
x
Reference in New Issue
Block a user