Merge branch 'MDL-38689_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-04-02 02:41:44 +02:00
commit 51cae58998
3 changed files with 89 additions and 2 deletions

View File

@ -89,7 +89,7 @@ class tool_behat_renderer extends plugin_renderer_base {
$stepsdefinitions = implode('', $stepsdefinitions);
// Replace text selector type arguments with a user-friendly select.
$stepsdefinitions = preg_replace_callback('/(TEXT_SELECTOR_STRING)/',
$stepsdefinitions = preg_replace_callback('/(TEXT_SELECTOR\d?_STRING)/',
function ($matches) {
return html_writer::select(behat_command::$allowedtextselectors, uniqid());
},
@ -97,7 +97,7 @@ class tool_behat_renderer extends plugin_renderer_base {
);
// Replace selector type arguments with a user-friendly select.
$stepsdefinitions = preg_replace_callback('/(SELECTOR_STRING)/',
$stepsdefinitions = preg_replace_callback('/(SELECTOR\d?_STRING)/',
function ($matches) {
return html_writer::select(behat_command::$allowedselectors, uniqid());
},

View File

@ -0,0 +1,33 @@
@backup
Feature: Duplicate activities
In order to set up my course contents quickly
As a moodle teacher
I need to duplicate activities inside the same course
@javascript
Scenario: Duplicate an activity
Given the following "courses" exists:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "users" exists:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "course enrolments" exists:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Database" to section "1" and I fill the form with:
| Name | Test database name |
| Description | Test database description |
When I click on "Duplicate" "link" in the "#section-1" "css_element"
And I press "Continue"
And I press "Edit the new copy"
And I fill the moodle form with:
| Name | Duplicated database name |
| Description | Duplicated database description |
And I press "Save and return to course"
Then I should see "Test database name" in the "#section-1" "css_element"
And I should see "Duplicated database name" in the "#section-1" "css_element"
And "Test database name" "link" should appear before "Duplicated database name" "link"

View File

@ -190,6 +190,60 @@ class behat_general extends behat_base {
$this->assertSession()->elementTextNotContains($selector, $locator, $text);
}
/**
* Checks, that the first specified element appears before the second one.
*
* @Given /^"(?P<preceding_element_string>(?:[^"]|\\")*)" "(?P<selector1_string>(?:[^"]|\\")*)" should appear before "(?P<following_element_string>(?:[^"]|\\")*)" "(?P<selector2_string>(?:[^"]|\\")*)"$/
* @throws ExpectationException
* @param string $preelement The locator of the preceding element
* @param string $preselectortype The locator of the preceding element
* @param string $postelement The locator of the latest element
* @param string $postselectortype The selector type of the latest element
*/
public function should_appear_before($preelement, $preselectortype, $postelement, $postselectortype) {
// We allow postselectortype as a non-text based selector.
list($preselector, $prelocator) = $this->transform_selector($preselectortype, $preelement);
list($postselector, $postlocator) = $this->transform_selector($postselectortype, $postelement);
$prexpath = $this->find($preselector, $prelocator)->getXpath();
$postxpath = $this->find($postselector, $postlocator)->getXpath();
// Using following xpath axe to find it.
$msg = '"'.$preelement.'" "'.$preselectortype.'" does not appear before "'.$postelement.'" "'.$postselectortype.'"';
$xpath = $prexpath.'/following::*[contains(., '.$postxpath.')]';
if (!$this->getSession()->getDriver()->find($xpath)) {
throw new ExpectationException($msg, $this->getSession());
}
}
/**
* Checks, that the first specified element appears after the second one.
*
* @Given /^"(?P<following_element_string>(?:[^"]|\\")*)" "(?P<selector1_string>(?:[^"]|\\")*)" should appear after "(?P<preceding_element_string>(?:[^"]|\\")*)" "(?P<selector2_string>(?:[^"]|\\")*)"$/
* @throws ExpectationException
* @param string $postelement The locator of the latest element
* @param string $postselectortype The selector type of the latest element
* @param string $preelement The locator of the preceding element
* @param string $preselectortype The locator of the preceding element
*/
public function should_appear_after($postelement, $postselectortype, $preelement, $preselectortype) {
// We allow postselectortype as a non-text based selector.
list($postselector, $postlocator) = $this->transform_selector($postselectortype, $postelement);
list($preselector, $prelocator) = $this->transform_selector($preselectortype, $preelement);
$postxpath = $this->find($postselector, $postlocator)->getXpath();
$prexpath = $this->find($preselector, $prelocator)->getXpath();
// Using preceding xpath axe to find it.
$msg = '"'.$postelement.'" "'.$postselectortype.'" does not appear after "'.$preelement.'" "'.$preselectortype.'"';
$xpath = $postxpath.'/preceding::*[contains(., '.$prexpath.')]';
if (!$this->getSession()->getDriver()->find($xpath)) {
throw new ExpectationException($msg, $this->getSession());
}
}
/**
* Checks, that element of specified type is disabled.
*