Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 6ba3bcd

Browse files
committed
Increased testing coverage
1 parent 99cdbf4 commit 6ba3bcd

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/UniversalTimestampTests.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function testFromMilliseconds()
4848
$this->assertGreaterThanOrEqual($uTs_A->asSeconds(), $classicTs_B);
4949
}
5050

51+
public function testFromStringTimestamp()
52+
{
53+
$classicTs_A = '2015-10-25 12:00:00';
54+
$uTs_A = UniversalTimestamp::fromStringTimestamp('2015-10-25 12:30:00');
55+
$classicTs_B = '2015-10-25 13:00:00';
56+
57+
$this->assertGreaterThanOrEqual($classicTs_A, $uTs_A->asFormattedString('Y-m-d H:i:s'));
58+
$this->assertGreaterThanOrEqual($uTs_A->asFormattedString('Y-m-d H:i:s'), $classicTs_B);
59+
}
60+
5161
/**
5262
* @expectedException \Litipk\Jiffy\JiffyException
5363
* @expectedExceptionMessage The number of milliseconds and microseconds must be positive
@@ -62,20 +72,22 @@ public function testFromWhatever()
6272
$ts1 = UniversalTimestamp::fromWhatever(1445817008639);
6373
$ts2 = UniversalTimestamp::fromWhatever(new \DateTime());
6474
$ts3 = UniversalTimestamp::fromWhatever(null);
75+
$ts4 = UniversalTimestamp::fromWhatever("2015-10-25 00:00:00");
6576

6677
$this->assertTrue($ts1 instanceof UniversalTimestamp);
6778
$this->assertTrue($ts2 instanceof UniversalTimestamp);
6879
$this->assertTrue($ts3 instanceof UniversalTimestamp);
80+
$this->assertTrue($ts4 instanceof UniversalTimestamp);
6981

7082
if (extension_loaded('mongo')) {
71-
$ts4 = UniversalTimestamp::fromWhatever(new \MongoDate());
72-
$this->assertTrue($ts4 instanceof UniversalTimestamp);
83+
$ts5 = UniversalTimestamp::fromWhatever(new \MongoDate());
84+
$this->assertTrue($ts5 instanceof UniversalTimestamp);
7385
}
7486
if (extension_loaded('mongodb')) {
75-
$ts4 = UniversalTimestamp::fromWhatever(
87+
$ts5 = UniversalTimestamp::fromWhatever(
7688
new \MongoDB\BSON\UTCDatetime(UniversalTimestamp::now()->asMilliseconds())
7789
);
78-
$this->assertTrue($ts4 instanceof UniversalTimestamp);
90+
$this->assertTrue($ts5 instanceof UniversalTimestamp);
7991
}
8092
}
8193

0 commit comments

Comments
 (0)