Merge branch 'MDL-38788_master' of git://github.com/dmonllao/moodle
This commit is contained in:
@@ -4,8 +4,7 @@ Feature: Add blocks
|
||||
As a teacher
|
||||
I need to add blocks to pages
|
||||
|
||||
@javascript
|
||||
Scenario: Add a block to a course
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
@@ -21,4 +20,9 @@ Feature: Add blocks
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
When I add the "Blog menu" block
|
||||
Then I should see "View all of my entries"
|
||||
Then I should see "View my entries about this course"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a block to a course with Javascript enabled
|
||||
|
||||
Scenario: Add a block to a course with Javascript disabled
|
||||
|
||||
@@ -46,7 +46,16 @@ class behat_blocks extends behat_base {
|
||||
* @param string $blockname
|
||||
*/
|
||||
public function i_add_the_block($blockname) {
|
||||
return new Given('I select "' . $blockname . '" from "bui_addblock"');
|
||||
$steps = new Given('I select "' . $blockname . '" from "bui_addblock"');
|
||||
|
||||
// If we are running without javascript we need to submit the form.
|
||||
if (!$this->running_javascript()) {
|
||||
$steps = array(
|
||||
$steps,
|
||||
new Given('I click on "Go" "button" in the "#add_block" "css_element"')
|
||||
);
|
||||
}
|
||||
return $steps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ Feature: Add activities to courses
|
||||
As a teacher
|
||||
I need to add activites to a course
|
||||
|
||||
@javascript
|
||||
Scenario: Add an activity to the course
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
@@ -19,8 +18,11 @@ Feature: Add activities to courses
|
||||
| student2 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
When I turn editing mode on
|
||||
And I add a "Database" to section "3" and I fill the form with:
|
||||
And I turn editing mode on
|
||||
|
||||
@javascript
|
||||
Scenario: Add an activity to a course
|
||||
When I add a "Database" to section "3" and I fill the form with:
|
||||
| Name | Test name |
|
||||
| Description | Test database description |
|
||||
| Required entries | 9 |
|
||||
@@ -35,21 +37,29 @@ Feature: Add activities to courses
|
||||
|
||||
@javascript
|
||||
Scenario: Add an activity without the required fields
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
| student2 | Student | 2 | student2@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
When I turn editing mode on
|
||||
And I add a "Database" to section "3" and I fill the form with:
|
||||
When I add a "Database" to section "3" and I fill the form with:
|
||||
| Name | Test name |
|
||||
Then I should see "Adding a new"
|
||||
And I should see "Required"
|
||||
|
||||
Scenario: Add an activity to a course with Javascript disabled
|
||||
Then I should see "Add a resource to section 'Topic 1'"
|
||||
And I should see "Add an activity to section 'Topic 1'"
|
||||
And I should see "Add a resource to section 'Topic 2'"
|
||||
And I should see "Add an activity to section 'Topic 2'"
|
||||
And I should see "Add a resource to section 'Topic 3'"
|
||||
And I should see "Add an activity to section 'Topic 3'"
|
||||
And I add a "Label" to section "2"
|
||||
And I should see "Adding a new Label to Topic 2"
|
||||
And I fill the moodle form with:
|
||||
| Label text | I'm a label |
|
||||
And I press "Save and return to course"
|
||||
And I add a "Database" to section "3"
|
||||
And I should see "Adding a new Database to Topic 3"
|
||||
And I fill the moodle form with:
|
||||
| Name | Test database name |
|
||||
| Description | Test database description |
|
||||
And I press "Save and return to course"
|
||||
And I should not see "Adding a new"
|
||||
And I should see "Test database name"
|
||||
And I should see "I'm a label"
|
||||
|
||||
@@ -83,15 +83,35 @@ class behat_course extends behat_base {
|
||||
*/
|
||||
public function i_add_to_section($activity, $section) {
|
||||
|
||||
// Clicks add activity or resource section link.
|
||||
$sectionxpath = "//*[@id='section-" . $section . "']/*/*/*/div[@class='section-modchooser']/span/a";
|
||||
$sectionnode = $this->find('xpath', $sectionxpath);
|
||||
$sectionnode->click();
|
||||
$sectionxpath = "//*[@id='section-" . $section . "']";
|
||||
|
||||
if ($this->running_javascript()) {
|
||||
|
||||
// Clicks add activity or resource section link.
|
||||
$sectionxpath = $sectionxpath . "/descendant::div[@class='section-modchooser']/span/a";
|
||||
$sectionnode = $this->find('xpath', $sectionxpath);
|
||||
$sectionnode->click();
|
||||
|
||||
// Clicks the selected activity if it exists.
|
||||
$activityxpath = ".//label[contains(.,'" . $activity . "')]/input";
|
||||
$activitynode = $this->find('xpath', $activityxpath);
|
||||
$activitynode->doubleClick();
|
||||
|
||||
} else {
|
||||
// Without Javascript.
|
||||
|
||||
// Selecting the option from the select box which contains the option.
|
||||
$selectxpath = $sectionxpath . "/descendant::div[contains(concat(' ', @class, ' '), ' section_add_menus ')]
|
||||
/descendant::select[contains(., '" . $activity . "')]";
|
||||
$selectnode = $this->find('xpath', $selectxpath);
|
||||
$selectnode->selectOption($activity);
|
||||
|
||||
// Go button.
|
||||
$gobuttonxpath = $selectxpath . "/ancestor::form/descendant::input[@type='submit']";
|
||||
$gobutton = $this->find('xpath', $gobuttonxpath);
|
||||
$gobutton->click();
|
||||
}
|
||||
|
||||
// Clicks the selected activity if it exists.
|
||||
$activityxpath = ".//label[contains(.,'" . $activity . "')]/input";
|
||||
$activitynode = $this->find('xpath', $activityxpath);
|
||||
$activitynode->doubleClick();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -176,7 +176,9 @@ class behat_forms extends behat_base {
|
||||
$selectnode->selectOption($option);
|
||||
|
||||
// Adding a click as Selenium requires it to fire some JS events.
|
||||
$selectnode->click();
|
||||
if ($this->running_javascript()) {
|
||||
$selectnode->click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +194,9 @@ class behat_forms extends behat_base {
|
||||
$radionode->check();
|
||||
|
||||
// Adding a click as Selenium requires it to fire some JS events.
|
||||
$radionode->click();
|
||||
if ($this->running_javascript()) {
|
||||
$radionode->click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user