icingaweb2/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php
jrauh01 3b9d663bcf
Replace array() with [] (#5509)
Replace the outdated `array()` spelling with the more modern `[]`. This
is applied throughout the whole project, also including phpdocs, tests,
view scripts and core modules.
2026-07-01 14:19:02 +02:00

48 lines
1.5 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Tests\Icinga\Web\Form\Element;
use DateTime;
use Icinga\Test\BaseTestCase;
use Icinga\Web\Form\Element\DateTimePicker;
class DateTimePickerTest extends BaseTestCase
{
public function testLocalDateAndTimeInput()
{
$dateTime = new DateTimePicker(
'name'
);
$now = new DateTime();
$this->assertTrue(
$dateTime->isValid($now->format('Y-m-d\TH:i:s')),
'A string representing a local date and time (with no timezone information) must be considered valid input'
);
$this->assertTrue(
$dateTime->getValue() instanceof DateTime,
'DateTimePicker::getValue() must return an instance of DateTime if its input is valid'
);
}
public function testRFC3339Input()
{
$dateTime = new DateTimePicker(
'name',
[
'local' => false
]
);
$now = new DateTime();
$this->assertTrue(
$dateTime->isValid($now->format(DateTime::RFC3339)),
'A string representing a global date and time (with timezone information) must be considered valid input'
);
$this->assertTrue(
$dateTime->getValue() instanceof DateTime,
'DateTimePicker::getValue() must return an instance of DateTime if its input is valid'
);
}
}