Permalink
Browse files

avoid failing tests by 1 second off

  • Loading branch information...
ceeram committed Feb 10, 2012
1 parent 028ba27 commit f8fef907c88d7ce0bd67e2d69b89b013b09db758
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php
@@ -915,7 +915,7 @@ public function testValidateHasManyRecordsPass() {
* @return void
*/
public function testValidateNestedNumericSets() {
-
+
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key'];
$unlocked = '';
@@ -1122,13 +1122,15 @@ public function testCsrfSettingMultipleNonces() {
$this->Security->validatePost = false;
$this->Security->csrfCheck = true;
$this->Security->csrfExpires = '+10 minutes';
+ $csrfExpires = strtotime('+10 minutes');
$this->Security->startup($this->Controller);
$this->Security->startup($this->Controller);
$token = $this->Security->Session->read('_Token');
$this->assertEquals(count($token['csrfTokens']), 2, 'Missing the csrf token.');
foreach ($token['csrfTokens'] as $key => $expires) {
- $this->assertEquals(strtotime('+10 minutes'), $expires, 'Token expiry does not match');
+ $diff = $csrfExpires - $expires;
+ $this->assertTrue($diff === 0 || $diff === 1, 'Token expiry does not match');
}
}

0 comments on commit f8fef90

Please sign in to comment.