From 0ef7a9d455734245f2f10e0de956ac14379433c6 Mon Sep 17 00:00:00 2001
From: Fred Emmott <fredemmott@fb.com>
Date: Mon, 18 Aug 2014 17:35:12 -0700
Subject: [PATCH] [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
---
 tests/lock/flock_test.php | 8 ++++----
 1 file 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');