Skip to content

Commit 9d7b9ee

Browse files
committed
Try to fix test
1 parent 3b3010c commit 9d7b9ee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/Gedmo/Timestampable/TimestampableDocumentTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Gedmo\Tests\Timestampable\Fixture\Document\Type;
1717
use Gedmo\Tests\Tool\BaseTestCaseMongoODM;
1818
use Gedmo\Timestampable\TimestampableListener;
19+
use MongoDB\BSON\Timestamp;
1920

2021
/**
2122
* These are tests for Timestampable behavior ODM implementation
@@ -41,7 +42,11 @@ public function testTimestampable(): void
4142

4243
$date = new \DateTime();
4344
$now = time();
44-
$created = $article->getCreated()->getTimestamp();
45+
$created = $article->getCreated();
46+
if ($created instanceof Timestamp) {
47+
$created = $created->getTimestamp();
48+
}
49+
4550
static::assertTrue($created > $now - 5 && $created < $now + 5); // 5 seconds interval if lag
4651
static::assertSame(
4752
$date->format('Y-m-d H:i'),

0 commit comments

Comments
 (0)