Skip to content

Commit 1475c76

Browse files
committed
Fixing failing tests
1 parent 0d5717b commit 1475c76

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

tests/TestCase/Model/Behavior/TimestampBehaviorTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Cake\ORM\Entity;
2020
use Cake\ORM\TableRegistry;
2121
use Cake\TestSuite\TestCase;
22+
use Cake\Utility\Time;
2223

2324
/**
2425
* Behavior test case
@@ -213,10 +214,8 @@ public function testGetTimestamp() {
213214
'Should return a timestamp object'
214215
);
215216

216-
$now = time();
217-
$ts = $return->getTimestamp();
218-
219-
$this->assertLessThan(3, abs($now - $ts), "Timestamp is expected to within 3 seconds of the current timestamp");
217+
$now = Time::now();
218+
$this->assertEquals($now, $return);
220219

221220
return $this->Behavior;
222221
}
@@ -374,12 +373,8 @@ public function testSaveTriggersInsert() {
374373

375374
$row = $table->find('all')->where(['id' => $entity->id])->first();
376375

377-
$now = time();
378-
379-
$storedValue = $row->created->getTimestamp();
380-
$this->assertLessThan(3, abs($storedValue - $now), "The stored created timestamp is expected to within 3 seconds of the current timestamp");
381-
382-
$storedValue = $row->updated->getTimestamp();
383-
$this->assertLessThan(3, abs($storedValue - $now), "The stored updated timestamp is expected to within 3 seconds of the current timestamp");
376+
$now = Time::now();
377+
$this->assertEquals($now, $row->created);
378+
$this->assertEquals($now, $row->updated);
384379
}
385380
}

0 commit comments

Comments
 (0)