diff --git a/tests/acceptance/features/bootstrap/Sharing.php b/tests/acceptance/features/bootstrap/Sharing.php index c972252946a6..68a92683674b 100644 --- a/tests/acceptance/features/bootstrap/Sharing.php +++ b/tests/acceptance/features/bootstrap/Sharing.php @@ -59,10 +59,21 @@ trait Sharing { private $userWhoCreatedLastPublicShare = null; /** + * Contains the API response to the last public link share that was created + * by the test-runner using the Sharing API. + * * @var SimpleXMLElement */ private $lastPublicShareData = null; + /** + * Contains the share id of the last public link share that was created by + * the test-runner, either using the Sharing API or on the web UI. + * + * @var string + */ + private $lastPublicShareId = null; + /** * @var int */ @@ -155,6 +166,7 @@ public function getSavedShareId():?int { */ public function resetLastPublicShareData():void { $this->lastPublicShareData = null; + $this->lastPublicShareId = null; $this->userWhoCreatedLastPublicShare = null; } @@ -1126,6 +1138,7 @@ public function createShare( if ($this->response->getStatusCode() === 204) { if ($shareType === 'public_link') { $this->lastPublicShareData = null; + $this->lastPublicShareId = null; $this->userWhoCreatedLastPublicShare = null; } else { $this->resetLastShareDataForUser($user); @@ -1133,6 +1146,7 @@ public function createShare( } else { if ($shareType === 'public_link') { $this->lastPublicShareData = $this->getResponseXml(null, __METHOD__); + $this->setLastPublicLinkShareId((string) $this->lastPublicShareData->data[0]->id); $this->userWhoCreatedLastPublicShare = $user; if (isset($this->lastPublicShareData->data)) { $linkName = (string) $this->lastPublicShareData->data[0]->name; @@ -2083,9 +2097,8 @@ public function theUserGetsInfoOfLastPublicLinkShareUsingTheSharingApi():void { * @throws Exception */ public function userGetsInfoOfLastPublicLinkShareUsingTheSharingApi(string $user, ?string $language = null):void { - $lastPublicShareData = $this->getLastPublicShareData(); - if ($lastPublicShareData !== null) { - $shareId = (string) $lastPublicShareData->data[0]->id; + if ($this->lastPublicShareId !== null) { + $shareId = $this->lastPublicShareId; } else { throw new Exception( __METHOD__ . " last public link share data was not found" @@ -2159,21 +2172,24 @@ public function getLastShareIdOf(string $user):?string { return $id; } + /** + * Sets the id of the last public link shared file + * + * @param string $shareId + * + * @return void + */ + public function setLastPublicLinkShareId(string $shareId):void { + $this->lastPublicShareId = $shareId; + } + /** * Retrieves the id of the last public link shared file * * @return string|null */ public function getLastPublicLinkShareId():?string { - $shareData = $this->getLastPublicShareData(); - if ($shareData->data) { - // id is a SimpleXMLElement object that contains the share id - // which is a string. - // (It might be a numeric string or might not, either is fine.) - return (string) $shareData->data[0]->id; - } else { - return null; - } + return $this->lastPublicShareId; } /** diff --git a/tests/acceptance/features/bootstrap/WebUISharingContext.php b/tests/acceptance/features/bootstrap/WebUISharingContext.php index 6bbfe78dcbc8..2595fb4e8cc7 100644 --- a/tests/acceptance/features/bootstrap/WebUISharingContext.php +++ b/tests/acceptance/features/bootstrap/WebUISharingContext.php @@ -789,6 +789,11 @@ 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"; + $this->featureContext->setLastPublicLinkShareId($shareId); $this->featureContext->addToListOfCreatedPublicLinks($linkName, $linkUrl); }