mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-70821 course: New Behat steps for activity dates
* activity_date_in_activity_should_contain_text() - Checks the presence of the given text in the activity's date info. * activity_dates_information_in_activity_should_exist() - Checks the presence of activity dates information in the activity information output component. * activity_dates_information_in_activity_should_not_exist() - Checks the absence of activity dates information in the activity information output component.
This commit is contained in:
parent
1c15796a75
commit
5dee6f45d8
@ -2035,4 +2035,53 @@ class behat_course extends behat_base {
|
||||
$node = $this->get_selected_node('xpath_element', '//div[@data-region="modules"]');
|
||||
$this->ensure_node_is_visible($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the presence of the given text in the activity's displayed dates.
|
||||
*
|
||||
* @Given /^the activity date in "(?P<activityname>(?:[^"]|\\")*)" should contain "(?P<text>(?:[^"]|\\")*)"$/
|
||||
* @param string $activityname The activity name.
|
||||
* @param string $text The text to be searched in the activity date.
|
||||
*/
|
||||
public function activity_date_in_activity_should_contain_text(string $activityname, string $text): void {
|
||||
$containerselector = "//div[@data-region='activity-information'][@data-activityname='$activityname']";
|
||||
$containerselector .= " /div[@data-region='activity-dates']";
|
||||
|
||||
$params = [$text, $containerselector, 'xpath_element'];
|
||||
$this->execute("behat_general::assert_element_contains_text", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the presence of activity dates information in the activity information output component.
|
||||
*
|
||||
* @Given /^the activity date information in "(?P<activityname>(?:[^"]|\\")*)" should exist$/
|
||||
* @param string $activityname The activity name.
|
||||
*/
|
||||
public function activity_dates_information_in_activity_should_exist(string $activityname): void {
|
||||
$containerselector = "//div[@data-region='activity-information'][@data-activityname='$activityname']";
|
||||
$elementselector = "/div[@data-region='activity-dates']";
|
||||
$params = [$elementselector, "xpath_element", $containerselector, "xpath_element"];
|
||||
$this->execute("behat_general::should_exist_in_the", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the absence of activity dates information in the activity information output component.
|
||||
*
|
||||
* @Given /^the activity date information in "(?P<activityname>(?:[^"]|\\")*)" should not exist$/
|
||||
* @param string $activityname The activity name.
|
||||
*/
|
||||
public function activity_dates_information_in_activity_should_not_exist(string $activityname): void {
|
||||
$containerselector = "//div[@data-region='activity-information'][@data-activityname='$activityname']";
|
||||
try {
|
||||
$this->find('xpath_element', $containerselector);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// If activity information container does not exist (activity dates not shown, completion info not shown), all good.
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, ensure that the completion information does not exist.
|
||||
$elementselector = "//div[@data-region='activity-dates']";
|
||||
$params = [$elementselector, "xpath_element", $containerselector, "xpath_element"];
|
||||
$this->execute("behat_general::should_not_exist_in_the", $params);
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ renderer and course format renderer:
|
||||
* A new callback xxx_coursemodule_definition_after_data that allows plugins to extend activity forms after the data is set.
|
||||
* \core_course_renderer::course_section_cm_completion() has been deprecated. It is not being used anymore and is being replaced by
|
||||
\core_renderer::activity_information().
|
||||
* New Behat steps for checking activity date information in the \behat_course class:
|
||||
- activity_date_in_activity_should_contain_text()
|
||||
- Given the activity date in "<ActivityName>" should contain "<Text>"
|
||||
- activity_dates_information_in_activity_should_exist()
|
||||
- Given the activity date information in "<ActivityName>" should exist
|
||||
- activity_dates_information_in_activity_should_not_exist()
|
||||
- Given the activity date information in "<ActivityName>" should not exist
|
||||
|
||||
=== 3.10 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user