From 5cc4434b630b1d86ed6f0ad8d20e360b8f276755 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 5 Jul 2017 17:19:52 +0200 Subject: [PATCH] Add conditional delay to avoid same stime in int test Should prevent the "Merging shares" test suites to fail randomly as the results order is dependent on the share time. --- tests/integration/features/bootstrap/Sharing.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/integration/features/bootstrap/Sharing.php b/tests/integration/features/bootstrap/Sharing.php index 960b36c4a6ee..75e06885c6a3 100644 --- a/tests/integration/features/bootstrap/Sharing.php +++ b/tests/integration/features/bootstrap/Sharing.php @@ -21,6 +21,9 @@ trait Sharing { /** @var int */ private $savedShareId = null; + /** @var int */ + private $lastShareTime = null; + /** * @Given /^as "([^"]*)" creating a share with$/ * @param string $user @@ -425,6 +428,14 @@ public function assureFileIsShared($entry, $filepath, $user1, $user2, $withPerms if ($this->isUserOrGroupInSharedData($user2, $permissions)){ return; } else { + $time = time(); + if ($this->lastShareTime !== null && $time - $this->lastShareTime < 1) { + // prevent creating two shares with the same "stime" which is based on + // seconds, this affects share merging order and could affect expected test + // result order + sleep(1); + } + $this->lastShareTime = $time; $this->createShare($user1, $filepath, 0, $user2, null, null, $permissions); } $this->response = $client->get($fullUrl, $options);