Skip to content

Commit

Permalink
Make CacheTest sleep properly
Browse files Browse the repository at this point in the history
This way it will always sleep for the right amount of time (or longer)
  • Loading branch information
ss23 committed Dec 21, 2013
1 parent 588118a commit 40163ed
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ public function testCacheLifetime() {
$cache->save('Good', 'cachekey');
$this->assertEquals('Good', $cache->load('cachekey'));

sleep(2);
// As per documentation, sleep may not sleep for the amount of time you tell it to sleep for
// This loop can make sure it *does* sleep for that long
$endtime = time() + 2;
while (time() < $endtime) {
// Sleep for another 2 seconds!
// This may end up sleeping for 4 seconds, but it's awwwwwwwright.
sleep(2);
}

$this->assertFalse($cache->load('cachekey'));
}
Expand Down

0 comments on commit 40163ed

Please sign in to comment.