Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make CacheTest sleep properly

This way it will always sleep for the right amount of time (or longer)
  • Loading branch information...
commit 40163edba77e67f6fe7aa884a4c1b8e6d599ff30 1 parent 588118a
@ss23 ss23 authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 tests/cache/CacheTest.php
View
9 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'));
}
Please sign in to comment.
Something went wrong with that request. Please try again.