Try to make some time related test failures go away.

This commit is contained in:
mark_story 2012-09-20 21:07:14 -04:00
parent a9750264e4
commit d3ba9703a5
2 changed files with 8 additions and 6 deletions

View file

@ -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);
}

View file

@ -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();
}