Permalink
Browse files

Make CacheTest sleep properly

This way it will always sleep for the right amount of time (or longer)
  • Loading branch information...
1 parent 588118a commit 40163edba77e67f6fe7aa884a4c1b8e6d599ff30 @ss23 ss23 committed Dec 21, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 tests/cache/CacheTest.php
@@ -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'));
}

0 comments on commit 40163ed

Please sign in to comment.