icingaweb2/test/php/library/Icinga/Web/Form/Element/DateTimePickerTest.php

47 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2015-02-03 15:49:34 +01:00
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */
namespace Tests\Icinga\Web\Form\Element;
2014-09-17 12:40:41 +02:00
use DateTime;
use Icinga\Test\BaseTestCase;
use Icinga\Web\Form\Element\DateTimePicker;
class DateTimePickerTest extends BaseTestCase
{
2014-09-17 12:40:41 +02:00
public function testLocalDateAndTimeInput()
{
2014-09-17 12:40:41 +02:00
$dateTime = new DateTimePicker(
'name'
);
2014-09-17 12:40:41 +02:00
$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'
);
2014-09-17 12:40:41 +02:00
$this->assertTrue(
$dateTime->getValue() instanceof DateTime,
'DateTimePicker::getValue() must return an instance of DateTime if its input is valid'
);
}
2014-09-17 12:40:41 +02:00
public function testRFC3339Input()
{
2014-09-17 12:40:41 +02:00
$dateTime = new DateTimePicker(
'name',
array(
2014-09-17 12:40:41 +02:00
'local' => false
)
);
2014-09-17 12:40:41 +02:00
$now = new DateTime();
$this->assertTrue(
2014-09-17 12:40:41 +02:00
$dateTime->isValid($now->format(DateTime::RFC3339)),
'A string representing a global date and time (with timezone information) must be considered valid input'
);
$this->assertTrue(
2014-09-17 12:40:41 +02:00
$dateTime->getValue() instanceof DateTime,
'DateTimePicker::getValue() must return an instance of DateTime if its input is valid'
);
}
}