From e0870dffec2e7c0fc85c10abb1aaa71f0865dc88 Mon Sep 17 00:00:00 2001
From: Alexander Bias <alexander.bias@uni-ulm.de>
Date: Sun, 14 Mar 2021 12:32:59 +0100
Subject: [PATCH] Fix Behat test for unrestricted self enrolment hint

---
 CHANGES.md                                    |  4 +
 ...oost_campus_course_layout_settings.feature | 92 ++++++++++++++-----
 2 files changed, 72 insertions(+), 24 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 565285b..4bb386d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,10 @@ moodle-theme_boost_campus
 Changes
 -------
 
+### Unreleased
+
+* 2021-03-14 - Fix Behat test for unrestricted self enrolment hint
+
 ### v3.10-r4
 
 * 2021-03-13 - Bugfix: Option to output the information banner without any particular Bootstrap color was broken on the login page.
diff --git a/tests/behat/theme_boost_campus_course_layout_settings.feature b/tests/behat/theme_boost_campus_course_layout_settings.feature
index 18a3b92..9b84c05 100644
--- a/tests/behat/theme_boost_campus_course_layout_settings.feature
+++ b/tests/behat/theme_boost_campus_course_layout_settings.feature
@@ -197,76 +197,120 @@ Feature: Configuring the theme_boost_campus plugin for the "Course Layout settin
     And I set the following fields to these values:
       | id_enrolstartdate_enabled | 0             |
       | id_enrolenddate_enabled   | 1             |
-      | id_enrolenddate           | ##yesterday## |
+    # We can't use the ##yesterday## notation here.
+      | id_enrolenddate_day       | 1             |
+      | id_enrolenddate_month     | January       |
+      | id_enrolenddate_year      | 2019          |
+      | id_enrolenddate_hour      | 00            |
+      | id_enrolenddate_minute    | 00            |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\""
     And ".course-selfenrol-infobox" "css_element" should not exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
-      | id_enrolstartdate_enabled | 0            |
-      | id_enrolenddate_enabled   | 1            |
-      | id_enrolenddate           | ##tomorrow## |
+      | id_enrolstartdate_enabled | 0             |
+      | id_enrolenddate_enabled   | 1             |
+    # We can't use the ##tomorrow## notation here. This test will break in the year 2050.
+      | id_enrolenddate_day       | 1             |
+      | id_enrolenddate_month     | January       |
+      | id_enrolenddate_year      | 2050          |
+      | id_enrolenddate_hour      | 00            |
+      | id_enrolenddate_minute    | 00            |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
     And ".course-selfenrol-infobox" "css_element" should exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
       | id_enrolstartdate_enabled | 1             |
-      | id_enrolstartdate         | ##yesterday## |
+    # We can't use the ##yesterday## notation here.
+      | id_enrolstartdate_day     | 1             |
+      | id_enrolstartdate_month   | January       |
+      | id_enrolstartdate_year    | 2019          |
+      | id_enrolstartdate_hour    | 00            |
+      | id_enrolstartdate_minute  | 00            |
       | id_enrolenddate_enabled   | 0             |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
     And ".course-selfenrol-infobox" "css_element" should exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
-      | id_enrolstartdate_enabled | 1            |
-      | id_enrolstartdate         | ##tomorrow## |
-      | id_enrolenddate_enabled   | 0            |
+      | id_enrolstartdate_enabled | 1             |
+    # We can't use the ##tomorrow## notation here. This test will break in the year 2050.
+      | id_enrolstartdate_day     | 1             |
+      | id_enrolstartdate_month   | January       |
+      | id_enrolstartdate_year    | 2050          |
+      | id_enrolstartdate_hour    | 00            |
+      | id_enrolstartdate_minute  | 00            |
+      | id_enrolenddate_enabled   | 0             |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
     And ".course-selfenrol-infobox" "css_element" should not exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
-      | id_enrolstartdate_enabled | 1                     |
-      | id_enrolstartdate         | ##Monday next week##  |
-      | id_enrolenddate_enabled   | 1                     |
-      | id_enrolenddate           | ##Tuesday next week## |
+      | id_enrolstartdate_enabled | 1             |
+    # We can't use the ##Monday next week## notation here. This test will break in the year 2050.
+      | id_enrolstartdate_day     | 1             |
+      | id_enrolstartdate_month   | January       |
+      | id_enrolstartdate_year    | 2050          |
+      | id_enrolstartdate_hour    | 00            |
+      | id_enrolstartdate_minute  | 00            |
+      | id_enrolenddate_enabled   | 1             |
+    # We can't use the ##Tuesday next week## notation here. This test will break in the year 2050.
+      | id_enrolenddate_day       | 2             |
+      | id_enrolenddate_month     | January       |
+      | id_enrolenddate_year      | 2050          |
+      | id_enrolenddate_hour      | 00            |
+      | id_enrolenddate_minute    | 00            |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
     And ".course-selfenrol-infobox" "css_element" should not exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
       | id_enrolstartdate_enabled | 1             |
-      | id_enrolstartdate         | ##yesterday## |
+    # We can't use the ##yesterday## notation here.
+      | id_enrolstartdate_day     | 1             |
+      | id_enrolstartdate_month   | January       |
+      | id_enrolstartdate_year    | 2019          |
+      | id_enrolstartdate_hour    | 00            |
+      | id_enrolstartdate_minute  | 00            |
       | id_enrolenddate_enabled   | 1             |
-      | id_enrolenddate           | ##tomorrow##  |
+    # We can't use the ##tomorrow## notation here. This test will break in the year 2050.
+      | id_enrolenddate_day       | 1             |
+      | id_enrolenddate_month     | January       |
+      | id_enrolenddate_year      | 2050          |
+      | id_enrolenddate_hour      | 00            |
+      | id_enrolenddate_minute    | 00            |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
     And ".course-selfenrol-infobox" "css_element" should exist
-
     When I navigate to "Users > Enrolment methods" in current page administration
     And I click on "Edit" "link" in the "Self enrolment (Student)" "table_row"
     And I set the following fields to these values:
-      | id_enrolstartdate_enabled | 1              |
-      | id_enrolstartdate         | ##3 days ago## |
-      | id_enrolenddate_enabled   | 1              |
-      | id_enrolenddate           | ##2 days ago## |
+      | id_enrolstartdate_enabled | 1             |
+    # We can't use the ##3 days ago## notation here.
+      | id_enrolstartdate_day     | 1             |
+      | id_enrolstartdate_month   | January       |
+      | id_enrolstartdate_year    | 2018          |
+      | id_enrolstartdate_hour    | 00            |
+      | id_enrolstartdate_minute  | 00            |
+      | id_enrolenddate_enabled   | 1             |
+    # We can't use the ##2 days ago## notation here.
+      | id_enrolenddate_day       | 1             |
+      | id_enrolenddate_month     | January       |
+      | id_enrolenddate_year      | 2019          |
+      | id_enrolenddate_hour      | 00            |
+      | id_enrolenddate_minute    | 00            |
     And I press "Save changes"
     And I am on "Course 1" course homepage
     Then I should not see "This course is currently visible and an unrestricted self enrolment is active: \"Self enrolment (Student)\"."
-- 
GitLab