Browse Source

Ensure tests do not rely in UTC default timezone

Six tests failed if the default timezone was not UTC. These were all due to faulty expectations, however, not faulty output.
microsub
J. King 6 years ago
parent
commit
3f65625090
  1. 2
      tests/cases/Misc/TestValueInfo.php
  2. 8
      tests/cases/REST/TinyTinyRSS/TestTinyTinyAPI.php
  3. 1
      tests/lib/AbstractTest.php
  4. 4
      tests/lib/Db/BindingTests.php

2
tests/cases/Misc/TestValueInfo.php

@ -456,7 +456,7 @@ class TestValueInfo extends Test\AbstractTest {
["Fri, 01 Jan 2010 00:00:00 GMT", null, null, null, $this->t(1262304000), null, null, null, null, null, null, $this->t(1262304000), ],
["2010-01-01 00:00:00", null, null, null, null, $this->t(1262304000), null, null, null, null, null, $this->t(1262304000), ],
["2010-01-01", null, null, null, null, null, $this->t(1262304000), null, null, null, null, $this->t(1262304000), ],
["12:34:56", null, null, null, null, null, null, $this->t(45296), null, null, null, $this->t(strtotime("today")+45296), ],
["12:34:56", null, null, null, null, null, null, $this->t(45296), null, null, null, $this->t(strtotime("Today UTC")+45296), ],
["1262304000", null, null, null, null, null, null, null, $this->t(1262304000), null, null, null, ],
["1262304000.123456", null, null, null, null, null, null, null, null, $this->t(1262304000.123456), null, null, ],
["1262304000.42", null, null, null, null, null, null, null, null, $this->t(1262304000.42), null, null, ],

8
tests/cases/REST/TinyTinyRSS/TestTinyTinyAPI.php

@ -1346,7 +1346,7 @@ LONG_STRING;
'published' => false,
'comments' => "",
'author' => '',
'updated' => strtotime('2000-01-01 00:00:01'),
'updated' => strtotime('2000-01-01T00:00:01Z'),
'feed_id' => "8",
'feed_title' => "Feed 11",
'attachments' => [],
@ -1369,7 +1369,7 @@ LONG_STRING;
'published' => false,
'comments' => "",
'author' => "J. King",
'updated' => strtotime('2000-01-02 00:00:02'),
'updated' => strtotime('2000-01-02T00:00:02Z'),
'feed_id' => "8",
'feed_title' => "Feed 11",
'attachments' => [
@ -1771,7 +1771,7 @@ LONG_STRING;
'marked' => false,
'published' => false,
'author' => '',
'updated' => strtotime('2000-01-01 00:00:00'),
'updated' => strtotime('2000-01-01T00:00:00Z'),
'is_updated' => false,
'feed_id' => "12",
'feed_title' => "Feed 2112",
@ -1796,7 +1796,7 @@ LONG_STRING;
'marked' => true,
'published' => false,
'author' => "J. King",
'updated' => strtotime('2000-01-02 00:00:02'),
'updated' => strtotime('2000-01-02T00:00:02Z'),
'is_updated' => true,
'feed_id' => "8",
'feed_title' => "Feed 11",

1
tests/lib/AbstractTest.php

@ -51,6 +51,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
}
public function clearData(bool $loadLang = true): bool {
date_default_timezone_set("America/Toronto");
$r = new \ReflectionClass(\JKingWeb\Arsse\Arsse::class);
$props = array_keys($r->getStaticProperties());
foreach ($props as $prop) {

4
tests/lib/Db/BindingTests.php

@ -195,7 +195,7 @@ trait BindingTests {
public function testBindIso8601DateString() {
$input = "2017-01-09T13:11:17";
$time = strtotime($input);
$time = strtotime($input." UTC");
$exp = [
"null" => null,
"integer" => 2017,
@ -213,7 +213,7 @@ trait BindingTests {
public function testBindArbitraryDateString() {
$input = "Today";
$time = strtotime($input);
$time = strtotime($input." UTC");
$exp = [
"null" => null,
"integer" => 0,

Loading…
Cancel
Save