Skip to content

Commit

Permalink
remove logic to store personal spaces of created users only
Browse files Browse the repository at this point in the history
  • Loading branch information
SwikritiT committed Aug 23, 2022
1 parent 14504a5 commit f4a78c8
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,31 +893,16 @@ public function theAdministratorGivesUserTheRole(string $user, string $role): vo
* @throws Exception
*/
public function rememberTheAvailableSpaces(): void {
$this->availableSpaces = [];
$rawBody = $this->featureContext->getResponse()->getBody()->getContents();
$drives = json_decode($rawBody, true, 512, JSON_THROW_ON_ERROR);
if (isset($drives["value"])) {
$drives = $drives["value"];
}

Assert::assertArrayHasKey(0, $drives, "No drives were found on that endpoint");
$spaces = [];
$createdUsers = $this->featureContext->getCreatedUsers();
$createdUsersId = array_column($createdUsers, 'id');
foreach ($drives as $drive) {
// when the user gets deleted the spaces related to user isn't deleted so we add only the spaces
// of users created by a paticular scenario to the array
// this work around can be removed after the fix of https://github.com/owncloud/ocis/issues/4195
if ($drive["name"] === 'Admin') {
$spaces[$drive["name"]] = $drive;
} elseif ($drive["driveType"] === 'personal') {
// get the user id of all the personal spaces availabe till now
$userId = $drive["owner"]["user"]["id"];
if (\in_array($userId, $createdUsersId)) {
$spaces[$drive["name"]] = $drive;
}
} elseif ($drive["driveType"] !== 'personal') {
$spaces[$drive["name"]] = $drive;
}
$spaces[$drive["name"]] = $drive;
}
$this->setAvailableSpaces($spaces);
Assert::assertNotEmpty($spaces, "No spaces have been found");
Expand Down Expand Up @@ -3062,7 +3047,7 @@ public function forUserSpaceShouldContainLinks(
string $fileName = ''
): void {
$body = '';
if (!empty ($fileName)) {
if (!empty($fileName)) {
$body = $this->getFileId($user, $spaceName, $fileName);
} else {
$space = $this->getSpaceByName($user, $spaceName);
Expand Down

0 comments on commit f4a78c8

Please sign in to comment.