From b86f11706b80972e3239c8ab0f24382b3b8dcf52 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Tue, 18 Mar 2014 15:45:07 -0700 Subject: [PATCH] Fix race condition in testExpiresAsString This race condition is common when running the tests with HHVM + JIT, due to JIT overhead when not warmed up. --- tests/SlimTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/SlimTest.php b/tests/SlimTest.php index e955e796b..047bd0d07 100644 --- a/tests/SlimTest.php +++ b/tests/SlimTest.php @@ -761,7 +761,6 @@ public function testExpiresAsString() 'SCRIPT_NAME' => '/foo', //<-- Physical 'PATH_INFO' => '/bar', //<-- Virtual )); - $expectedDate = gmdate('D, d M Y H:i:s T', strtotime('5 days')); $s = new \Slim\Slim(); $s->get('/bar', function () use ($s) { $s->expires('5 days'); @@ -769,7 +768,12 @@ public function testExpiresAsString() $s->call(); list($status, $header, $body) = $s->response()->finalize(); $this->assertTrue(isset($header['Expires'])); - $this->assertEquals($header['Expires'], $expectedDate); + + $this->assertEquals( + strtotime('5 days'), + strtotime($header['Expires']), + 1 // delta + ); } /**