From a3a24239825f141ebb4d323d6ca9841b2682ac71 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Thu, 1 May 2014 11:18:06 +0100 Subject: [PATCH] MDL-45362 Availability: Behat test fails on first of month --- .../condition/date/classes/condition.php | 5 ++--- .../tests/behat/display_availability.feature | 22 +++++++++++++++++-- .../tests/behat/edit_availability.feature | 11 ++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/availability/condition/date/classes/condition.php b/availability/condition/date/classes/condition.php index 3c048274dc8..c1b3bbad6f4 100644 --- a/availability/condition/date/classes/condition.php +++ b/availability/condition/date/classes/condition.php @@ -204,10 +204,9 @@ class condition extends \core_availability\condition { * timezone). * * @param int $time Time - * @return bool True if time refers to midnight, false if it's some other - * time or if it is set to zero + * @return bool True if time refers to midnight, false otherwise */ protected static function is_midnight($time) { - return $time && usergetmidnight($time) == $time; + return usergetmidnight($time) == $time; } } diff --git a/availability/tests/behat/display_availability.feature b/availability/tests/behat/display_availability.feature index 80770de59d1..d9db6512fd8 100644 --- a/availability/tests/behat/display_availability.feature +++ b/availability/tests/behat/display_availability.feature @@ -4,6 +4,24 @@ Feature: display_availability As a user I need to see appropriate availability restrictions for activities and sections + # PURPOSE OF THIS TEST FEATURE: + # + # This test is to do a basic check of the user interface relating to display + # of availability conditions - i.e. if there's a condition, does it show up; + # are we doing the HTML correctly; does it correctly hide an activity where + # the options are set to not show it at all. + # + # Things this test is not: + # - It is not a test of the date condition specifically. The date condition is + # only used as an example in order to get the availability information to + # display. (The date condition has its own Behat test in + # /availability/condition/date/tests/behat.) + # - It is not a complete test of the logic. This is supposed to be a shallow + # check of the user interface parts and doesn't cover all logical + # possibilities. The logic is tested in PHPUnit tests instead, which are + # much more efficient. (Again there are unit tests for the overall system + # and for each condition type.) + Background: Given the following "courses" exist: | fullname | shortname | format | @@ -39,7 +57,7 @@ Feature: display_availability And I click on "Date" "button" in the "Add restriction..." "dialogue" And I set the field "direction" to "until" And I set the field "x[year]" to "2013" - And I set the field "x[month]" to "January" + And I set the field "x[month]" to "March" And I press "Save and return to course" # Add a Page with 2 restrictions - one is set to hide from students if failed. @@ -53,7 +71,7 @@ Feature: display_availability And I click on "Date" "button" in the "Add restriction..." "dialogue" And I set the field "direction" to "until" And I set the field "x[year]" to "2013" - And I set the field "x[month]" to "January" + And I set the field "x[month]" to "March" And I click on ".availability-item .availability-eye img" "css_element" And I press "Add restriction..." And I click on "User profile" "button" in the "Add restriction..." "dialogue" diff --git a/availability/tests/behat/edit_availability.feature b/availability/tests/behat/edit_availability.feature index 45c1c685b84..3f2e3a2112c 100644 --- a/availability/tests/behat/edit_availability.feature +++ b/availability/tests/behat/edit_availability.feature @@ -4,6 +4,17 @@ Feature: edit_availability As a teacher I need to set up availability options for activities and sections + # PURPOSE OF THIS TEST FEATURE: + # + # This test covers the user interface around editing availability conditions, + # especially the JavaScript code which is not tested elsewhere (e.g. does the + # 'Add restriction' dialog work). It tests both forms and also the admin + # setting interface. + # + # This test does not check the detailed behaviour of the availability system, + # which is mainly covered in PHPUnit (and, from the user interface + # perspective, in the other Behat tests for each type of condition). + Background: Given the following "courses" exist: | fullname | shortname | format |