diff --git a/lib/behat/form_field/behat_form_date_time_selector.php b/lib/behat/form_field/behat_form_date_time.php similarity index 70% rename from lib/behat/form_field/behat_form_date_time_selector.php rename to lib/behat/form_field/behat_form_date_time.php index 19181cf6b40a9..f1344603adfdd 100644 --- a/lib/behat/form_field/behat_form_date_time_selector.php +++ b/lib/behat/form_field/behat_form_date_time.php @@ -25,7 +25,7 @@ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -require_once(__DIR__ . '/behat_form_date_selector.php'); +require_once(__DIR__ . '/behat_form_date.php'); /** * Date time form field. @@ -38,5 +38,18 @@ * @copyright 2013 David MonllaĆ³ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class behat_form_date_time_selector extends behat_form_date_selector { +class behat_form_date_time extends behat_form_date { + + /** + * Returns the date field identifiers and the values that should be assigned to them. + * + * @param int $timestamp The UNIX timestamp + * @return array + */ + protected function get_mapped_fields(int $timestamp): array { + return array_merge(parent::get_mapped_fields($timestamp), [ + 'hour' => date('G', $timestamp), + 'minute' => (int) date('i', $timestamp) + ]); + } } diff --git a/lib/form/templates/element-date_time_selector.mustache b/lib/form/templates/element-date_time_selector.mustache index a78ad2e68007a..b1a267f0950e9 100644 --- a/lib/form/templates/element-date_time_selector.mustache +++ b/lib/form/templates/element-date_time_selector.mustache @@ -1,6 +1,6 @@ {{< core_form/element-group }} {{$element}} -
+
{{label}}
{{#element.elements}} diff --git a/lib/upgrade.txt b/lib/upgrade.txt index f44e080d4d864..c064e0a075e11 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -7,6 +7,9 @@ information provided here is intended especially for developers. * Behat now supports date selection from the date form element. Examples: - I set the field "" to "##15 March 2021##" - I set the field "" to "##first day of January last year##" +* Behat now supports date and time selection from the datetime form element. Examples: + - I set the field "" to "##15 March 2021 08:15##" + - I set the field "" to "##first day of January last year noon##" === 3.10 === * PHPUnit has been upgraded to 8.5. That comes with a few changes: