diff --git a/tests/acceptance/features/bootstrap/WebUISharingContext.php b/tests/acceptance/features/bootstrap/WebUISharingContext.php index 060d13fc7f13..1c788cc639e5 100644 --- a/tests/acceptance/features/bootstrap/WebUISharingContext.php +++ b/tests/acceptance/features/bootstrap/WebUISharingContext.php @@ -159,26 +159,9 @@ private function addToListOfCreatedPublicLinks($name, $url) { public function theUserSharesFileFolderWithUserUsingTheWebUI( $folder, $remote, $user, $maxRetries = STANDARD_RETRY_COUNT, $quiet = false ) { - $this->filesPage->waitTillPageIsloaded($this->getSession()); - try { - $this->filesPage->closeDetailsDialog(); - } catch (Exception $e) { - //we don't care - } - $this->sharingDialog = $this->filesPage->openSharingDialog( - $folder, $this->getSession() + $this->theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( + $folder, "user", $remote, $user, $maxRetries, $quiet ); - $user = $this->featureContext->substituteInLineCodes($user); - if ($remote === "remote") { - $this->sharingDialog->shareWithRemoteUser( - $user, $this->getSession(), $maxRetries, $quiet - ); - } else { - $this->sharingDialog->shareWithUser( - $user, $this->getSession(), $maxRetries, $quiet - ); - } - $this->theUserClosesTheShareDialog(); } /** @@ -195,6 +178,25 @@ public function theUserSharesFileFolderWithUserUsingTheWebUI( */ public function theUserSharesFileFolderWithGroupUsingTheWebUI( $folder, $group, $maxRetries = STANDARD_RETRY_COUNT, $quiet = false + ) { + $this->theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( + $folder, "group", "", $group, $maxRetries, $quiet + ); + } + + /** + * @param string $folder + * @param string $userOrGroup + * @param string $remote + * @param string $name + * @param int $maxRetries + * @param bool $quiet + * + * @return void + * @throws \Exception + */ + public function theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( + $folder, $userOrGroup, $remote, $name, $maxRetries = STANDARD_RETRY_COUNT, $quiet = false ) { $this->filesPage->waitTillPageIsloaded($this->getSession()); try { @@ -205,9 +207,22 @@ public function theUserSharesFileFolderWithGroupUsingTheWebUI( $this->sharingDialog = $this->filesPage->openSharingDialog( $folder, $this->getSession() ); - $this->sharingDialog->shareWithGroup( - $group, $this->getSession(), $maxRetries, $quiet - ); + if ($userOrGroup === "user") { + $user = $this->featureContext->substituteInLineCodes($name); + if ($remote === "remote") { + $this->sharingDialog->shareWithRemoteUser( + $user, $this->getSession(), $maxRetries, $quiet + ); + } else { + $this->sharingDialog->shareWithUser( + $user, $this->getSession(), $maxRetries, $quiet + ); + } + } else { + $this->sharingDialog->shareWithGroup( + $name, $this->getSession(), $maxRetries, $quiet + ); + } $this->theUserClosesTheShareDialog(); } @@ -1200,15 +1215,9 @@ public function itShouldNotBePossibleToShareFileFolderUsingTheWebUI( ) { $sharingWasPossible = false; try { - if ($userOrGroup === "user") { - $this->theUserSharesFileFolderWithUserUsingTheWebUI( - $fileName, null, $shareWith, 2, true - ); - } else { - $this->theUserSharesFileFolderWithGroupUsingTheWebUI( - $fileName, $shareWith, 2, true - ); - } + $this->theUserSharesFileFolderWithUserOrGroupUsingTheWebUI( + $fileName, $userOrGroup, "", $shareWith, 2, true + ); $sharingWasPossible = true; } catch (ElementNotFoundException $e) { if ($shareWith === null) {