From d3ba9703a5602caaca4dd039f8065727e8579788 Mon Sep 17 00:00:00 2001 From: mark_story <mark@mark-story.com> Date: Thu, 20 Sep 2012 21:07:14 -0400 Subject: [PATCH] Try to make some time related test failures go away. --- .../Case/Controller/Component/CookieComponentTest.php | 4 +++- lib/Cake/Test/Case/Utility/FileTest.php | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php index 6ed65a673..380c29099 100644 --- a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php @@ -271,12 +271,14 @@ class CookieComponentTest extends CakeTestCase { $expected = array( 'name' => $this->Cookie->name . '[Testing]', 'value' => '[1,2,3]', - 'expire' => time() + 10, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false); $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); + + $this->assertWithinMargin($result['expire'], time() + 10, 1); + unset($result['expire']); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Utility/FileTest.php b/lib/Cake/Test/Case/Utility/FileTest.php index 93c7227be..01799519d 100644 --- a/lib/Cake/Test/Case/Utility/FileTest.php +++ b/lib/Cake/Test/Case/Utility/FileTest.php @@ -362,11 +362,10 @@ class FileTest extends CakeTestCase { * @return void */ public function testLastAccess() { - $ts = time(); $someFile = new File(TMP . 'some_file.txt', false); $this->assertFalse($someFile->lastAccess()); $this->assertTrue($someFile->open()); - $this->assertTrue($someFile->lastAccess() >= $ts); + $this->assertWithinMargin($someFile->lastAccess(), time(), 2); $someFile->close(); $someFile->delete(); } @@ -377,13 +376,14 @@ class FileTest extends CakeTestCase { * @return void */ public function testLastChange() { - $ts = time(); $someFile = new File(TMP . 'some_file.txt', false); $this->assertFalse($someFile->lastChange()); $this->assertTrue($someFile->open('r+')); - $this->assertTrue($someFile->lastChange() >= $ts); + $this->assertWithinMargin($someFile->lastChange(), time(), 2); + $someFile->write('something'); - $this->assertTrue($someFile->lastChange() >= $ts); + $this->assertWithinMargin($someFile->lastChange(), time(), 2); + $someFile->close(); $someFile->delete(); }