MDL-70732 behat: Adding second parameter to ExpectationException()

This commit is contained in:
Amaia Anabitarte 2021-01-28 17:09:50 +01:00
parent 4e398ff3f7
commit 248d4ff200
3 changed files with 9 additions and 5 deletions

View File

@ -1360,7 +1360,8 @@ class behat_course extends behat_base {
try {
return $DB->get_field('course_categories', 'id', array('idnumber' => $idnumber), MUST_EXIST);
} catch (dml_missing_record_exception $ex) {
throw new ExpectationException(sprintf("There is no category in the database with the idnumber '%s'", $idnumber));
throw new ExpectationException(sprintf("There is no category in the database with the idnumber '%s'", $idnumber),
$this->getSession());
}
}
@ -1378,7 +1379,8 @@ class behat_course extends behat_base {
try {
return $DB->get_field('course', 'id', array('idnumber' => $idnumber), MUST_EXIST);
} catch (dml_missing_record_exception $ex) {
throw new ExpectationException(sprintf("There is no course in the database with the idnumber '%s'", $idnumber));
throw new ExpectationException(sprintf("There is no course in the database with the idnumber '%s'", $idnumber),
$this->getSession());
}
}

View File

@ -1575,7 +1575,7 @@ EOF;
if ($content !== $expectedcontent) {
throw new ExpectationException('Image is not identical to the fixture. Received ' .
strlen($content) . ' bytes and expected ' . strlen($expectedcontent) . ' bytes');
strlen($content) . ' bytes and expected ' . strlen($expectedcontent) . ' bytes', $this->getSession());
}
}
@ -1860,7 +1860,8 @@ EOF;
list($modifier, $char) = preg_split('/-/', $key, 2);
$modifier = strtolower($modifier);
if (!in_array($modifier, $validmodifiers)) {
throw new ExpectationException(sprintf('Unknown key modifier: %s.', $modifier));
throw new ExpectationException(sprintf('Unknown key modifier: %s.', $modifier),
$this->getSession());
}
}
if (is_numeric($char)) {

View File

@ -417,7 +417,8 @@ class behat_mod_quiz extends behat_question_base {
} else if (preg_match('~Page (\d+)~', $pageorlast, $matches)) {
$xpath = "//li[@id = 'page-{$matches[1]}']//a[contains(@data-toggle, 'dropdown') and contains(., 'Add')]";
} else {
throw new ExpectationException("The I open the add to quiz menu step must specify either 'Page N' or 'last'.");
throw new ExpectationException("The I open the add to quiz menu step must specify either 'Page N' or 'last'.",
$this->getSession());
}
$this->find('xpath', $xpath)->click();
}