From 40163edba77e67f6fe7aa884a4c1b8e6d599ff30 Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Sat, 21 Dec 2013 15:05:51 +1300 Subject: [PATCH] Make CacheTest sleep properly This way it will always sleep for the right amount of time (or longer) --- tests/cache/CacheTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/cache/CacheTest.php b/tests/cache/CacheTest.php index 639a9b2dd..a9d81b9d5 100644 --- a/tests/cache/CacheTest.php +++ b/tests/cache/CacheTest.php @@ -27,7 +27,14 @@ class CacheTest extends SapphireTest { $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')); }