Browse files

Make flaky tests less flaky.

Off by one second errors are common here.
  • Loading branch information...
1 parent 94e83fa commit ca2c122c62a9dab02b6ddae553013658843df036 @markstory markstory committed Apr 18, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
View
16 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
@@ -684,21 +684,21 @@ public function testSessionTimeout() {
TestCakeSession::destroy();
TestCakeSession::write('Test', 'some value');
- $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime);
+ $this->assertWithinMargin(time() + $timeoutSeconds, CakeSession::$sessionTime, 1);
$this->assertEquals(10, $_SESSION['Config']['countdown']);
- $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']);
- $this->assertEquals(time(), CakeSession::$time);
- $this->assertEquals(time() + $timeoutSeconds, $_SESSION['Config']['time']);
+ $this->assertWithinMargin(CakeSession::$sessionTime, $_SESSION['Config']['time'], 1);
+ $this->assertWithinMargin(time(), CakeSession::$time, 1);
+ $this->assertWithinMargin(time() + $timeoutSeconds, $_SESSION['Config']['time'], 1);
Configure::write('Session.harden', true);
TestCakeSession::destroy();
TestCakeSession::write('Test', 'some value');
- $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime);
+ $this->assertWithinMargin(time() + $timeoutSeconds, CakeSession::$sessionTime, 1);
$this->assertEquals(10, $_SESSION['Config']['countdown']);
- $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']);
- $this->assertEquals(time(), CakeSession::$time);
- $this->assertEquals(CakeSession::$time + $timeoutSeconds, $_SESSION['Config']['time']);
+ $this->assertWithinMargin(CakeSession::$sessionTime, $_SESSION['Config']['time'], 1);
+ $this->assertWithinMargin(time(), CakeSession::$time, 1);
+ $this->assertWithinMargin(CakeSession::$time + $timeoutSeconds, $_SESSION['Config']['time'], 1);
}
/**

0 comments on commit ca2c122

Please sign in to comment.