Skip to content

Commit

Permalink
Refactor theUserSharesFileFolderWithUserOrGroupUsingTheWebUI
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jun 6, 2019
1 parent 80922de commit 0eff143
Showing 1 changed file with 40 additions and 31 deletions.
71 changes: 40 additions & 31 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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 {
Expand All @@ -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();
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0eff143

Please sign in to comment.