1441 |
ariadna |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
|
|
18 |
|
|
|
19 |
require_once(__DIR__ . '/behat_form_text.php');
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Class for <input type="datetime-local"> fields.
|
|
|
23 |
*
|
|
|
24 |
* @package core
|
|
|
25 |
* @category test
|
|
|
26 |
* @author Mark Johnson <mark.johnson@catalyst-eu.net>
|
|
|
27 |
* @copyright 2024 Catalyst IT Europe Ltd
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class behat_form_datetime_local extends behat_form_text {
|
|
|
31 |
/**
|
|
|
32 |
* Sets the datetime-local value.
|
|
|
33 |
*
|
|
|
34 |
* Typing the value in like a text field isn't reliable cross-browser, so instead we need to set the value directly with
|
|
|
35 |
* Javascript.
|
|
|
36 |
*
|
|
|
37 |
* @param string $value Date and time in a format like 2024-10-01T10:00
|
|
|
38 |
* @return void
|
|
|
39 |
*/
|
|
|
40 |
public function set_value($value): void {
|
|
|
41 |
$this->require_javascript('Setting a datatime-local field requires Javascript.');
|
|
|
42 |
$this->execute_js_on_node($this->field, "{{ELEMENT}}.value = '{$value}'");
|
|
|
43 |
}
|
|
|
44 |
}
|