Skip to content

Commit 4dc9b6d

Browse files
author
Jacob Middag
committed
Improve unit test of time assertion
1 parent d2cdc8e commit 4dc9b6d

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

test/unit/TinyPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testCompressShouldUpdateMetadata() {
115115

116116
$metadata = $this->wp->getMetadata(1, 'tiny_compress_images', true);
117117
foreach ($metadata as $key => $values) {
118-
$this->assertEquals(time(), $values['end'], 2);
118+
$this->assertBetween(-1, +1, $values['end'] - time());
119119
unset($metadata[$key]['end']);
120120
unset($metadata[$key]['start']);
121121
}

test/unit/TinyTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ protected function setUp() {
2727

2828
protected function tearDown() {
2929
}
30+
31+
protected function assertBetween($lower_bound, $upper_bound, $actual, $message='') {
32+
$this->assertGreaterThanOrEqual($lower_bound, $actual, $message);
33+
$this->assertLessThanOrEqual($upper_bound, $actual, $message);
34+
}
3035
}

0 commit comments

Comments
 (0)