Skip to content

Commit baed84d

Browse files
committed
Unit tests for ISO8601 formats
* Particularly around timezone output handling
1 parent 7ab52f5 commit baed84d

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/ISO8601Test.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/*
3+
Copyright 2014 Rustici Software
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
use TinCan\Statement;
19+
use TinCan\State;
20+
21+
class ISO8601Test extends PHPUnit_Framework_TestCase {
22+
public function testProperties() {
23+
$str_datetime = '2014-12-15T19:16:05+00:00';
24+
$str_datetime_tz = '2014-12-15T13:16:05-06:00';
25+
26+
$datetime = new \DateTime();
27+
$datetime->setDate(2014, 12, 15);
28+
$datetime->setTime(19, 16, 05);
29+
30+
$statement = new Statement();
31+
$statement->setStored($datetime);
32+
$statement->setTimestamp($datetime);
33+
34+
$document = new State();
35+
$document->setTimestamp($datetime);
36+
37+
$this->assertEquals($statement->getStored(), $str_datetime, 'stored matches');
38+
$this->assertEquals($statement->getTimestamp(), $str_datetime, 'timestamp matches');
39+
$this->assertEquals($document->getTimestamp(), $str_datetime, 'document timestamp matches');
40+
41+
$datetime->setTimezone(new DateTimeZone('America/Chicago'));
42+
$statement->setStored($datetime);
43+
$statement->setTimestamp($datetime);
44+
$document->setTimestamp($datetime);
45+
46+
$this->assertEquals($statement->getStored(), $str_datetime_tz, 'stored matches');
47+
$this->assertEquals($statement->getTimestamp(), $str_datetime_tz, 'timestamp matches');
48+
$this->assertEquals($document->getTimestamp(), $str_datetime_tz, 'document timestamp matches');
49+
}
50+
}

0 commit comments

Comments
 (0)