Skip to content

Commit

Permalink
Fix some of the behat errors
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Nov 14, 2023
1 parent 6998088 commit bfeacf1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
43 changes: 34 additions & 9 deletions tests/behat/behat_block_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,41 @@ public function i_should_watch_the_video_in_opencast() {
}

/**
* adds a breakpoints
* stops the execution until you hit enter in the console
* @Then /^breakpoint in ocblock/
* Checks whether the given lti tool has the given custom parameter.
*
* @Then /^the lti tool "([^"]*)" should have the custom parameter "([^"]*)"$/
*
* @param string $ltitoolname
* @param string $customparameter
*/
public function breakpoint_in_ocblock() {
fwrite(STDOUT, "\033[s \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue...\033[0m");
while (fgets(STDIN, 1024) == '') {
continue;
public function the_lti_tool_should_have_the_custom_parameter($ltitoolname, $customparameter) {
global $DB;

$ltitool = $DB->get_record('lti', ['name' => $ltitoolname]);
if ($ltitool->instructorcustomparameters !== $customparameter) {
throw new ExpectationException("$ltitoolname has custom parameter \"$ltitool->instructorcustomparameters\"" .
" instead of expected \"$customparameter\"", $this->getSession());
}
}

/**
* Checks whether the given lti tool has the given custom parameter.
*
* @Then /^the lti tool "([^"]*)" in the course "([^"]*)" should have the custom parameter "([^"]*)"$/
*
* @param string $ltitoolname
* @param string $course
* @param string $customparameter
*/
public function the_lti_tool_in_the_course_should_have_the_custom_parameter($ltitoolname, $course, $customparameter) {
global $DB;

$cid = $this->get_course_id($course);

$ltitool = $DB->get_record('lti', ['name' => $ltitoolname, 'course' => $cid]);
if ($ltitool->instructorcustomparameters !== $customparameter) {
throw new ExpectationException("$ltitoolname has custom parameter \"$ltitool->instructorcustomparameters\"".
" instead of expected \"$customparameter\"", $this->getSession());
}
fwrite(STDOUT, "\033[u");
return;
}
}
6 changes: 1 addition & 5 deletions tests/behat/block_opencast_addlti.feature
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ Feature: Add Opencast LTI series module as Teacher
Then I should see "Course 1" in the "#page-header" "css_element"
And I should see "The 'Opencast videos' series module has been added to this course."
And I should see "Opencast videos" in the "li.activity" "css_element"
And I am on "Course 1" course homepage with editing mode on
And I open "Opencast videos" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Preconfigured tool" matches value "Opencast series"
# Now, the field "Custom parameters" should also contain the Opencast series ID, but we can't test that with Behat
And the lti tool "Opencast videos" should have the custom parameter "series=1234-1234-1234-1234-1234"
And I am on "Course 1" course homepage
And I click on "Go to overview..." "link"
Then "View Opencast LTI series module in course" "link" should exist
Expand Down
19 changes: 4 additions & 15 deletions tests/behat/block_opencast_cleanup_backup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ Feature: Restore courses as Teacher
And I click on "Add module and return to overview" "button"
And I click on "Add Opencast episode module to course" "link"
And I click on "Add module and return to course" "button"
And I open "Opencast videos" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Custom parameters" matches value "series=1234-1234-1234-1234-1234"
When I click on "Cancel" "button"
And I open "Test video" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Custom parameters" matches value "id=abcd-abcd-abcd-abcd"
When I click on "Cancel" "button"
Then the lti tool "Opencast videos" should have the custom parameter "series=1234-1234-1234-1234-1234"
And the lti tool "Test video" should have the custom parameter "id=abcd-abcd-abcd-abcd"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
| Schema | Include videos from Opencast instance Default in this course | 0 |
Expand All @@ -99,13 +93,8 @@ Feature: Restore courses as Teacher
Then I should see "The import of the selected videos into this course was scheduled"
And I run the scheduled task "\block_opencast\task\cleanup_imported_episodes_cron"
And I am on "Course 1 copy 1" course homepage with editing mode on
And I open "Opencast videos" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Custom parameters" matches value "series=84bab8de-5688-46a1-9af0-5ce9122eeb6a"
When I click on "Cancel" "button"
And I open "Test video" actions menu
And I choose "Edit settings" in the open action menu
Then the field "Custom parameters" matches value "id=abcd-abcd-abcd-abcd"
Then the lti tool "Opencast videos" in the course "Course 1 copy 1" should have the custom parameter "series=84bab8de-5688-46a1-9af0-5ce9122eeb6a"
Then the lti tool "Test video" in the course "Course 1 copy 1" should have the custom parameter "id=abcd-abcd-abcd-abcd"
And I run all adhoc tasks
And the following config values are set as admin:
| config | value | plugin |
Expand Down

0 comments on commit bfeacf1

Please sign in to comment.