Skip to content

Commit

Permalink
save shareId of public link shares created via the webUI
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed May 30, 2022
1 parent 47d42db commit 43a39a1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
9 changes: 8 additions & 1 deletion tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,14 @@ public function userHasRemovedAllSharesFromTheFileNamed(string $user, string $fi
}

/**
* Returns shares of a file or folders as an array of elements
* Returns shares of a file or folder as a SimpleXMLElement
*
* Note: the "single" SimpleXMLElement may contain one or more actual
* shares (to users, groups or public links etc). If you access an item directly,
* for example, getShares()->id, then the value of "id" for the first element
* will be returned. To access all the elements, you can loop through the
* returned SimpleXMLElement with "foreach" - it will act like a PHP array
* of elements.
*
* @param string $user
* @param string $path
Expand Down
25 changes: 22 additions & 3 deletions tests/acceptance/features/bootstrap/WebUISharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,29 @@ public function theUserCreatesANewPublicLinkForFileFolderUsingTheWebUIWith(
):void {
$linkName = $this->createPublicShareLink($name, $settings);
$linkUrl = $this->publicShareTab->getLinkUrl($linkName);
// ToDo: need to find out the share id of the public link share that was just created on the webUI
$urlParts = \explode("/", $linkUrl);
$shareId = \end($urlParts);
echo "\nshare id '$shareId'\n";
$shareToken = \end($urlParts);
// Find the share id of the share that has this share token.
// We want to remember it so that later "Then" steps can check
// attributes of the "last public link share" by using the share id to
// access the sharing API.
$currentUser = $this->featureContext->getCurrentUser();
$shareData = $this->featureContext->getShares($currentUser, $name);
$shareId = null;
foreach ($shareData as $shareItem) {
if ((string) $shareItem->token === $shareToken) {
$shareId = (string) $shareItem->id;
break;
}
}
if ($shareId === null) {
// Fail early here. We know that there was some trouble with the share.
// It will be confusing if we continue to later steps that try to use
// a non-existent share id.
throw new Exception(
__METHOD__ . " share with token '$shareToken' for user '$currentUser' could not be found."
);
}
$this->featureContext->setLastPublicLinkShareId($shareId);
$this->featureContext->addToListOfCreatedPublicLinks($linkName, $linkUrl);
}
Expand Down

0 comments on commit 43a39a1

Please sign in to comment.