From 3982685a3cd7af06d4c7d902fedec1f3cd916d7a Mon Sep 17 00:00:00 2001 From: gthomas2 Date: Mon, 19 Dec 2016 13:00:22 +0000 Subject: [PATCH] MDL-57452 behat: Make completion check work with manual completion input --- completion/tests/behat/behat_completion.php | 6 ++++-- completion/tests/behat/enable_manual_complete_mark.feature | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/completion/tests/behat/behat_completion.php b/completion/tests/behat/behat_completion.php index 5d80be04f7c..c85f83d2e0d 100644 --- a/completion/tests/behat/behat_completion.php +++ b/completion/tests/behat/behat_completion.php @@ -121,13 +121,14 @@ class behat_completion extends behat_base { public function activity_marked_as_complete($activityname, $activitytype, $completiontype) { if ($completiontype == "manual") { $imgalttext = get_string("completion-alt-manual-y", 'core_completion', $activityname); + $xpathtocheck = "//input[@type='image'][contains(@alt, '$imgalttext')]"; } else { $imgalttext = get_string("completion-alt-auto-y", 'core_completion', $activityname); + $xpathtocheck = "//img[contains(@alt, '$imgalttext')]"; } $activityxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]"; $activityxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]"; - $xpathtocheck = "//img[contains(@alt, '$imgalttext')]"; $this->execute("behat_general::should_exist_in_the", array($xpathtocheck, "xpath_element", $activityxpath, "xpath_element") ); @@ -142,13 +143,14 @@ class behat_completion extends behat_base { public function activity_marked_as_not_complete($activityname, $activitytype, $completiontype) { if ($completiontype == "manual") { $imgalttext = get_string("completion-alt-manual-n", 'core_completion', $activityname); + $xpathtocheck = "//input[@type='image'][contains(@alt, '$imgalttext')]"; } else { $imgalttext = get_string("completion-alt-auto-n", 'core_completion', $activityname); + $xpathtocheck = "//img[contains(@alt, '$imgalttext')]"; } $activityxpath = "//li[contains(concat(' ', @class, ' '), ' modtype_" . strtolower($activitytype) . " ')]"; $activityxpath .= "[descendant::*[contains(text(), '" . $activityname . "')]]"; - $xpathtocheck = "//img[contains(@alt, '$imgalttext')]"; $this->execute("behat_general::should_exist_in_the", array($xpathtocheck, "xpath_element", $activityxpath, "xpath_element") ); diff --git a/completion/tests/behat/enable_manual_complete_mark.feature b/completion/tests/behat/enable_manual_complete_mark.feature index c7aeb270ae6..443dc220e57 100644 --- a/completion/tests/behat/enable_manual_complete_mark.feature +++ b/completion/tests/behat/enable_manual_complete_mark.feature @@ -25,15 +25,16 @@ Feature: Allow students to manually mark an activity as complete And I set the following fields to these values: | Enable completion tracking | Yes | And I press "Save and display" - When I add a "Forum" to section "1" and I fill the form with: + And I add a "Forum" to section "1" and I fill the form with: | Forum name | Test forum name | | Description | Test forum description | - Then "Student First" user has not completed "Test forum name" activity + And "Student First" user has not completed "Test forum name" activity And I log out And I log in as "student1" And I am on site homepage And I follow "Course 1" - And I press "Mark as complete: Test forum name" + When I press "Mark as complete: Test forum name" + Then the "Test forum name" "forum" activity with "manual" completion should be marked as complete And I log out And I log in as "teacher1" And I am on site homepage