Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make flaky tests less flaky.

Off by one second errors are common here.
  • Loading branch information...
commit ca2c122c62a9dab02b6ddae553013658843df036 1 parent 94e83fa
Mark Story markstory authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
16 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
View
@@ -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);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.