Skip to content

Commit

Permalink
Merge branch 'MDL-39795_25' of git://github.com/dmonllao/moodle into …
Browse files Browse the repository at this point in the history
…MOODLE_25_STABLE
  • Loading branch information
stronk7 committed May 27, 2013
2 parents a665577 + 0653761 commit d6e2b0a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backup/util/ui/tests/behat/restore_moodle2_courses.feature
Expand Up @@ -88,7 +88,7 @@ Feature: Restore Moodle 2 course backups
| id_startdate_year | 2020 | | id_startdate_year | 2020 |
| id_format | Weekly format | | id_format | Weekly format |
And I press "Save changes" And I press "Save changes"
And I should see "1 January - 7 January" And I should see "1 January - 7 January"
And I should see "Test forum name" And I should see "Test forum name"
And I follow "Edit settings" And I follow "Edit settings"
And I expand all fieldsets And I expand all fieldsets
Expand Down
26 changes: 22 additions & 4 deletions lib/tests/behat/behat_general.php
Expand Up @@ -214,23 +214,41 @@ public function i_drag_and_i_drop_it_in($element, $selectortype, $containereleme
/** /**
* Checks, that page contains specified text. * Checks, that page contains specified text.
* *
* @see Behat\MinkExtension\Context\MinkContext
* @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)"$/ * @Then /^I should see "(?P<text_string>(?:[^"]|\\")*)"$/
* @throws ExpectationException
* @param string $text * @param string $text
*/ */
public function assert_page_contains_text($text) { public function assert_page_contains_text($text) {
$this->assertSession()->pageTextContains($text);
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
$xpath = "/descendant::*[contains(., " . $xpathliteral. ")]";

// Wait until it finds the text, otherwise custom exception.
try {
$this->find('xpath', $xpath);
} catch (ElementNotFoundException $e) {
throw new ExpectationException('"' . $text . '" text was not found in the page', $this->getSession());
}
} }


/** /**
* Checks, that page doesn't contain specified text. * Checks, that page doesn't contain specified text.
* *
* @see Behat\MinkExtension\Context\MinkContext
* @Then /^I should not see "(?P<text_string>(?:[^"]|\\")*)"$/ * @Then /^I should not see "(?P<text_string>(?:[^"]|\\")*)"$/
* @throws ExpectationException
* @param string $text * @param string $text
*/ */
public function assert_page_not_contains_text($text) { public function assert_page_not_contains_text($text) {
$this->assertSession()->pageTextNotContains($text);
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
$xpath = "/descendant::*[not(contains(., " . $xpathliteral. "))]";

// Wait until it finds the text, otherwise custom exception.
try {
$this->find('xpath', $xpath);
} catch (ElementNotFoundException $e) {
throw new ExpectationException('"' . $text . '" text was found in the page', $this->getSession());
}
} }


/** /**
Expand Down
18 changes: 11 additions & 7 deletions lib/tests/behat/behat_hooks.php
Expand Up @@ -277,14 +277,18 @@ public function i_look_for_exceptions() {
} }


// Any other backtrace. // Any other backtrace.
$backtracespattern = '/(line [0-9]* of [^:]*: call to [\->&;:a-zA-Z_\x7f-\xff][\->&;:a-zA-Z0-9_\x7f-\xff]*)/'; // First looking through xpath as it is faster than get and parse the whole page contents,
if (preg_match_all($backtracespattern, $this->getSession()->getPage()->getContent(), $backtraces)) { // we get the contents and look for matches once we found something to suspect that there is a backtrace.
$msgs = array(); if ($this->getSession()->getDriver()->find("(//html/descendant::*[contains(., ': call to ')])[1]")) {
foreach ($backtraces[0] as $backtrace) { $backtracespattern = '/(line [0-9]* of [^:]*: call to [\->&;:a-zA-Z_\x7f-\xff][\->&;:a-zA-Z0-9_\x7f-\xff]*)/';
$msgs[] = $backtrace . '()'; if (preg_match_all($backtracespattern, $this->getSession()->getPage()->getContent(), $backtraces)) {
$msgs = array();
foreach ($backtraces[0] as $backtrace) {
$msgs[] = $backtrace . '()';
}
$msg = "Other backtraces found:\n" . implode("\n", $msgs);
throw new \Exception(htmlentities($msg));
} }
$msg = "Other backtraces found:\n" . implode("\n", $msgs);
throw new \Exception(htmlentities($msg));
} }


} catch (NoSuchWindow $e) { } catch (NoSuchWindow $e) {
Expand Down
5 changes: 3 additions & 2 deletions mod/lesson/tests/behat/time_limit.feature
Expand Up @@ -39,10 +39,11 @@ Feature: A teacher can set a time limit for a lesson
And I wait "3" seconds And I wait "3" seconds
And I should see "Time remaining" And I should see "Time remaining"
And I press "Single button" And I press "Single button"
And I should see " 0:00:" And I should see "0:00:"
And I should see "Warning: You have 1 minute or less to finish the lesson." And I should see "Warning: You have 1 minute or less to finish the lesson."
And I wait "60" seconds And I wait "60" seconds
And I press "Single button" And I press "Single button"
And I should see "Attention: You ran out of time for this lesson. Your last answer may not have counted if it was answered after the time was up." And I should see "You ran out of time for this lesson."
And I should see "Your last answer may not have counted if it was answered after the time was up."
And I should see "Congratulations - end of lesson reached" And I should see "Congratulations - end of lesson reached"
And I should not see "Single lesson page contents" And I should not see "Single lesson page contents"

0 comments on commit d6e2b0a

Please sign in to comment.