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

This commit is contained in:
Dan Poltawski 2013-10-07 11:26:37 +08:00
commit d1050e406f
5 changed files with 45 additions and 19 deletions

View File

@ -36,7 +36,7 @@ Feature: Page contents assertions
And I log in as "admin"
And I follow "Course 1"
When I click on "Move this to the dock" "button" in the "Administration" "block"
Then I should not see "Question bank"
Then I should not see "Question bank" in the "region-pre" "region"
And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
@javascript
@ -46,4 +46,4 @@ Feature: Page contents assertions
| Course 1 | C1 | 0 |
And I log in as "admin"
When I click on "Move this to the dock" "button" in the "Administration" "block"
Then I should not see "Turn editing on"
Then I should not see "Turn editing on" in the "region-pre" "region"

View File

@ -32,5 +32,5 @@ Feature: Forms manipulation
Then I should see "Close the quiz"
And I should see "Group mode"
And I should see "Grouping"
And I should not see "Show more..."
And I should not see "Show more..." in the "region-main-box" "region"
And I should see "Show less..."

View File

@ -285,7 +285,7 @@ class behat_general extends behat_base {
public function assert_page_contains_text($text) {
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
$xpath = "/descendant::*[contains(., $xpathliteral)]";
$xpath = "/descendant-or-self::*[contains(., $xpathliteral)]";
// Wait until it finds the text, otherwise custom exception.
try {
@ -304,45 +304,69 @@ class behat_general extends behat_base {
*/
public function assert_page_not_contains_text($text) {
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
$xpath = "/descendant::*[not(contains(., $xpathliteral))]";
// Wait until it finds the text, otherwise custom exception.
// Delegating the process to assert_page_contains_text.
try {
$this->find('xpath', $xpath);
} catch (ElementNotFoundException $e) {
throw new ExpectationException('"' . $text . '" text was found in the page', $this->getSession());
$this->assert_page_contains_text($text);
} catch (ExpectationException $e) {
// It should not appear, so this is good.
return;
}
// If the page contains the text this is failing.
throw new ExpectationException('"' . $text . '" text was found in the page', $this->getSession());
}
/**
* Checks, that element with specified CSS selector or XPath contains specified text.
*
* @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)" in the "(?P<element_string>(?:[^"]|\\")*)" "(?P<text_selector_string>[^"]*)"$/
* @throws ElementNotFoundException
* @throws ExpectationException
* @param string $text
* @param string $element Element we look in.
* @param string $selectortype The type of element where we are looking in.
*/
public function assert_element_contains_text($text, $element, $selectortype) {
// Transforming from steps definitions selector/locator format to Mink format.
list($selector, $locator) = $this->transform_text_selector($selectortype, $element);
$this->assertSession()->elementTextContains($selector, $locator, $text);
// Getting the container where the text should be found.
$container = $this->get_selected_node($selectortype, $element);
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
$xpath = "/descendant-or-self::*[contains(., $xpathliteral)]";
// Wait until it finds the text inside the container, otherwise custom exception.
try {
$this->find('xpath', $xpath, false, $container);
} catch (ElementNotFoundException $e) {
throw new ExpectationException('"' . $text . '" text was not found in the ' . $element . ' element', $this->getSession());
}
}
/**
* Checks, that element with specified CSS selector or XPath doesn't contain specified text.
*
* @Then /^I should not see "(?P<text_string>(?:[^"]|\\")*)" in the "(?P<element_string>(?:[^"]|\\")*)" "(?P<text_selector_string>[^"]*)"$/
* @throws ElementNotFoundException
* @throws ExpectationException
* @param string $text
* @param string $element Element we look in.
* @param string $selectortype The type of element where we are looking in.
*/
public function assert_element_not_contains_text($text, $element, $selectortype) {
// Transforming from steps definitions selector/locator format to mink format.
list($selector, $locator) = $this->transform_text_selector($selectortype, $element);
$this->assertSession()->elementTextNotContains($selector, $locator, $text);
// Delegating the process to assert_element_contains_text.
try {
$this->assert_element_contains_text($text, $element, $selectortype);
} catch (ExpectationException $e) {
// It should not appear, so this is good.
// We only catch ExpectationException as ElementNotFoundException
// will be thrown if the container does not exist.
return;
}
// If the element contains the text this is failing.
throw new ExpectationException('"' . $text . '" text was found in the ' . $element . ' element', $this->getSession());
}
/**

View File

@ -56,5 +56,5 @@ Feature: Students can edit or delete their forum posts within a set time limit
Scenario: Time limit expires
When I wait "70" seconds
And I follow "Forum post subject"
Then I should not see "Edit"
And I should not see "Delete"
Then I should not see "Edit" in the "region-main" "region"
And I should not see "Delete" in the "region-main" "region"

View File

@ -13,7 +13,9 @@ Feature: Delete files and folders from the file manager
And I create "Delete me" folder in "Files" filepicker
And I press "Save changes"
When I delete "empty.txt" from "Files" filepicker
And I press "Save changes"
Then I should not see "empty.txt"
And I delete "Delete me" from "Files" filepicker
And I press "Save changes"
And I should not see "Delete me"
And I press "Cancel"