summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-06-09 03:03:47 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-06-09 03:03:47 +0200
commit423136d31950bb12258d23258aab0abb6c552106 (patch)
tree46935540c7e8f6b6e12a55b411dc529b152998dc /tests
parentbe02b3df28ca9e2f45316594c2caaa680e74f676 (diff)
downloadnextcloud-server-423136d31950bb12258d23258aab0abb6c552106.tar.gz
nextcloud-server-423136d31950bb12258d23258aab0abb6c552106.zip
Extract duplicated code to a method
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php43
1 files changed, 15 insertions, 28 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 9d8e05a1325..52f69c66796 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -432,20 +432,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @When I see that the :tabName tab in the details view is eventually loaded
*/
public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) {
- $timeout = 10;
- $timeoutStep = 1;
-
- $actor = $this->actor;
- $loadingIcon = self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName);
-
- $loadingIconNotFoundCallback = function() use ($actor, $loadingIcon) {
- try {
- return !$actor->find($loadingIcon)->isVisible();
- } catch (NoSuchElementException $exception) {
- return true;
- }
- };
- if (!Utils::waitFor($loadingIconNotFoundCallback, $timeout, $timeoutStep)) {
+ if (!$this->waitForElementToBeEventuallyNotShown(self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName), $timeout = 10)) {
PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds");
}
}
@@ -461,20 +448,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @Then I see that the working icon for password protect is eventually not shown
*/
public function iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown() {
- $timeout = 10;
- $timeoutStep = 1;
-
- $actor = $this->actor;
- $passwordProtectWorkingIcon = self::passwordProtectWorkingIcon();
-
- $workingIconNotFoundCallback = function() use ($actor, $passwordProtectWorkingIcon) {
- try {
- return !$actor->find($passwordProtectWorkingIcon)->isVisible();
- } catch (NoSuchElementException $exception) {
- return true;
- }
- };
- if (!Utils::waitFor($workingIconNotFoundCallback, $timeout, $timeoutStep)) {
+ if (!$this->waitForElementToBeEventuallyNotShown(self::passwordProtectWorkingIcon(), $timeout = 10)) {
PHPUnit_Framework_Assert::fail("The working icon for password protect is still shown after $timeout seconds");
}
}
@@ -489,4 +463,17 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown();
}
+ private function waitForElementToBeEventuallyNotShown($elementLocator, $timeout = 10, $timeoutStep = 1) {
+ $actor = $this->actor;
+
+ $elementNotFoundCallback = function() use ($actor, $elementLocator) {
+ try {
+ return !$actor->find($elementLocator)->isVisible();
+ } catch (NoSuchElementException $exception) {
+ return true;
+ }
+ };
+
+ return Utils::waitFor($elementNotFoundCallback, $timeout, $timeoutStep);
+ }
}