Skip to content

Commit 7fe4611

Browse files
Michael FeroMichael Penick
authored andcommitted
test: Fix constant and assert test for cpp-driver v2.4.2
1 parent 65310cf commit 7fe4611

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/unit/Cassandra/DateTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
class DateTest extends \PHPUnit_Framework_TestCase
2525
{
26-
const SECONDS_PER_DAY = 24 * 60 * 60;
26+
const SECONDS_PER_DAY = 86400;
2727

2828
public function testConstruct()
2929
{
@@ -54,12 +54,14 @@ public function testFromDateTime()
5454
// Epoch + 1
5555
$datetime = new \DateTime("1970-01-02T00:00:00+0000");
5656
$date = Date::fromDateTime($datetime);
57-
$this->assertEquals($date->seconds(), 24 * 60 * 60);
57+
$this->assertEquals($date->seconds(), self::SECONDS_PER_DAY);
5858
$this->assertEquals($date->toDateTime(), $datetime);
5959

6060
// Epoch - 1 (should work if cpp-driver >= 2.4.2, otherwise it's broken)
61-
//$date = Date::fromDateTime(new \DateTime("1969-12-31T00:00:00"));
62-
//$this->assertEquals($date->seconds(), -24 * 60 * 60);
61+
if (version_compare(\Cassandra::CPP_DRIVER_VERSION, "2.4.2") >= 0) {
62+
$date = Date::fromDateTime(new \DateTime("1969-12-31T00:00:00"));
63+
$this->assertEquals($date->seconds(), -1 * self::SECONDS_PER_DAY);
64+
}
6365
}
6466

6567
public function testToDateTimeWithTime()

0 commit comments

Comments
 (0)