aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lock
diff options
context:
space:
mode:
authorFred Emmott <fredemmott@fb.com>2014-08-18 17:35:12 -0700
committerAndreas Fischer <bantu@phpbb.com>2014-08-19 11:53:34 +0200
commit0ef7a9d455734245f2f10e0de956ac14379433c6 (patch)
tree7c85458dc8c16ae10a909d223d416c159ad3fc5c /tests/lock
parenta82a88b555c8cecef1758f32518c9dcb21283bda (diff)
downloadforums-0ef7a9d455734245f2f10e0de956ac14379433c6.tar
forums-0ef7a9d455734245f2f10e0de956ac14379433c6.tar.gz
forums-0ef7a9d455734245f2f10e0de956ac14379433c6.tar.bz2
forums-0ef7a9d455734245f2f10e0de956ac14379433c6.tar.xz
forums-0ef7a9d455734245f2f10e0de956ac14379433c6.zip
[ticket/12996] Fix reliability issue in flock test.
$delta was always an int - so, this test would sometimes fail if you happened to call time() /very/ close to a 1s boundary. Found by HHVM's continuous testing. PHPBB3-12996
Diffstat (limited to 'tests/lock')
-rw-r--r--tests/lock/flock_test.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php
index 0ff38b6cc8..554b7e57f4 100644
--- a/tests/lock/flock_test.php
+++ b/tests/lock/flock_test.php
@@ -83,9 +83,9 @@ class phpbb_lock_flock_test extends phpbb_test_case
sleep(1);
$lock = new \phpbb\lock\flock($path);
- $start = time();
+ $start = microtime(true);
$ok = $lock->acquire();
- $delta = time() - $start;
+ $delta = microtime(true) - $start;
$this->assertTrue($ok);
$this->assertTrue($lock->owns_lock());
$this->assertGreaterThan(0.5, $delta, 'First lock acquired too soon');
@@ -94,9 +94,9 @@ class phpbb_lock_flock_test extends phpbb_test_case
$this->assertFalse($lock->owns_lock());
// acquire again, this should be instantaneous
- $start = time();
+ $start = microtime(true);
$ok = $lock->acquire();
- $delta = time() - $start;
+ $delta = microtime(true) - $start;
$this->assertTrue($ok);
$this->assertTrue($lock->owns_lock());
$this->assertLessThan(0.1, $delta, 'Second lock not acquired instantaneously');