diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index e976ce47b7f..bbff084028d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -12,6 +12,20 @@ ->exclude($excludeDirs) ->in(__DIR__); -$config = new OC\CodingStandard\Config(); +$ocRule = (new OC\CodingStandard\Config())->getRules(); +$config = new PhpCsFixer\Config(); +$config->setFinder($finder) + ->setIndent("\t") + ->setRules( + array_merge( + $ocRule, + [ + "return_type_declaration" => [ + "space_before" => "none", + ], + 'single_space_around_construct' => true + ] + ) + ); $config->setFinder($finder); return $config; diff --git a/phpcs.xml b/phpcs.xml index a3b644170c2..925d2c72937 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -19,10 +19,6 @@ - - - - @@ -77,4 +73,18 @@ */lib/storagewrapper.php + + Please review this TODO comment: %s + error + + + + + + + error + + + + diff --git a/tests/acceptance/TestHelpers/Asserts/WebDav.php b/tests/acceptance/TestHelpers/Asserts/WebDav.php index 155d5ff1c9d..343708413ab 100644 --- a/tests/acceptance/TestHelpers/Asserts/WebDav.php +++ b/tests/acceptance/TestHelpers/Asserts/WebDav.php @@ -42,7 +42,7 @@ public static function assertDavResponseElementIs( ?string $expectedValue, ?array $responseXmlArray, ?string $extraErrorText = '' - ):void { + ): void { if ($extraErrorText !== '') { $extraErrorText = $extraErrorText . " "; } @@ -58,7 +58,9 @@ public static function assertDavResponseElementIs( } elseif ($element === "reason") { $result = $responseXmlArray['value'][3]['value']; } else { - self::fail(__METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in."); + self::fail( + __METHOD__ . " element must be one of exception, response or reason. But '$element' was passed in." + ); } self::assertEquals( @@ -78,7 +80,7 @@ public static function assertDavResponseElementIs( public static function assertResponseContainsShareTypes( SimpleXMLElement $responseXmlObject, ?array $expectedShareTypes - ):void { + ): void { foreach ($expectedShareTypes as $row) { $xmlPart = $responseXmlObject->xpath( "//d:prop/oc:share-types/oc:share-type[.=" . $row[0] . "]" diff --git a/tests/acceptance/TestHelpers/AuthAppHelper.php b/tests/acceptance/TestHelpers/AuthAppHelper.php index 61d76d5ddd4..c42f5f4d8f5 100644 --- a/tests/acceptance/TestHelpers/AuthAppHelper.php +++ b/tests/acceptance/TestHelpers/AuthAppHelper.php @@ -42,7 +42,11 @@ public static function getAuthAppEndpoint(): string { * * @return ResponseInterface */ - public static function listAllAppAuthTokensForUser(string $baseUrl, string $user, string $password): ResponseInterface { + public static function listAllAppAuthTokensForUser( + string $baseUrl, + string $user, + string $password + ): ResponseInterface { $url = $baseUrl . self::getAuthAppEndpoint(); return HttpRequestHelper::sendRequest( $url, @@ -61,7 +65,12 @@ public static function listAllAppAuthTokensForUser(string $baseUrl, string $user * * @return ResponseInterface */ - public static function createAppAuthToken(string $baseUrl, string $user, string $password, string $expiration): ResponseInterface { + public static function createAppAuthToken( + string $baseUrl, + string $user, + string $password, + string $expiration + ): ResponseInterface { $url = $baseUrl . self::getAuthAppEndpoint() . "?expiry=$expiration"; return HttpRequestHelper::sendRequest( $url, @@ -80,7 +89,12 @@ public static function createAppAuthToken(string $baseUrl, string $user, string * * @return ResponseInterface */ - public static function deleteAppAuthToken(string $baseUrl, string $user, string $password, string $token): ResponseInterface { + public static function deleteAppAuthToken( + string $baseUrl, + string $user, + string $password, + string $token + ): ResponseInterface { $url = $baseUrl . self::getAuthAppEndpoint() . "?token=$token"; return HttpRequestHelper::sendRequest( $url, diff --git a/tests/acceptance/TestHelpers/BehatHelper.php b/tests/acceptance/TestHelpers/BehatHelper.php index 83c485969a8..5fd4fd5367f 100644 --- a/tests/acceptance/TestHelpers/BehatHelper.php +++ b/tests/acceptance/TestHelpers/BehatHelper.php @@ -38,7 +38,11 @@ class BehatHelper { * * @return Context */ - public static function getContext(ScenarioScope $scope, InitializedContextEnvironment $environment, string $class): Context { + public static function getContext( + ScenarioScope $scope, + InitializedContextEnvironment $environment, + string $class + ): Context { try { return $environment->getContext($class); } catch (ContextNotFoundException $e) { diff --git a/tests/acceptance/TestHelpers/EmailHelper.php b/tests/acceptance/TestHelpers/EmailHelper.php index bc09e81314c..03e613e5278 100644 --- a/tests/acceptance/TestHelpers/EmailHelper.php +++ b/tests/acceptance/TestHelpers/EmailHelper.php @@ -35,7 +35,7 @@ class EmailHelper { * * @return string */ - public static function getMailBoxFromEmail(string $emailAddress):string { + public static function getMailBoxFromEmail(string $emailAddress): string { return explode("@", $emailAddress)[0]; } @@ -45,7 +45,7 @@ public static function getMailBoxFromEmail(string $emailAddress):string { * * @return string */ - public static function getLocalEmailUrl():string { + public static function getLocalEmailUrl(): string { $localEmailHost = self::getLocalEmailHost(); $emailPort = \getenv('EMAIL_PORT'); if ($emailPort === false) { @@ -60,7 +60,7 @@ public static function getLocalEmailUrl():string { * * @return string */ - public static function getEmailHost():string { + public static function getEmailHost(): string { $emailHost = \getenv('EMAIL_HOST'); if ($emailHost === false) { $emailHost = "127.0.0.1"; @@ -74,7 +74,7 @@ public static function getEmailHost():string { * * @return string */ - public static function getLocalEmailHost():string { + public static function getLocalEmailHost(): string { $localEmailHost = \getenv('LOCAL_EMAIL_HOST'); if ($localEmailHost === false) { $localEmailHost = self::getEmailHost(); @@ -92,7 +92,7 @@ public static function getLocalEmailHost():string { * @return array * @throws GuzzleException */ - public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null):array { + public static function getMailBoxInformation(string $mailBox, ?string $xRequestId = null): array { $response = HttpRequestHelper::get( self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox, $xRequestId, @@ -113,7 +113,11 @@ public static function getMailBoxInformation(string $mailBox, ?string $xRequestI * @return object * @throws GuzzleException */ - public static function getBodyOfAnEmailById(string $mailBox, string $mailboxId, ?string $xRequestId = null):object { + public static function getBodyOfAnEmailById( + string $mailBox, + string $mailboxId, + ?string $xRequestId = null + ): object { $response = HttpRequestHelper::get( self::getLocalEmailUrl() . "/api/v1/mailbox/" . $mailBox . "/" . $mailboxId, $xRequestId, @@ -142,7 +146,7 @@ public static function getBodyOfLastEmail( string $xRequestId, ?int $emailNumber = 1, ?int $waitTimeSec = EMAIL_WAIT_TIMEOUT_SEC - ):string { + ): string { $currentTime = \time(); $endTime = $currentTime + $waitTimeSec; $mailBox = self::getMailBoxFromEmail($emailAddress); @@ -178,7 +182,7 @@ public static function deleteAllEmailsForAMailbox( string $localInbucketUrl, ?string $xRequestId, string $mailBox - ):ResponseInterface { + ): ResponseInterface { return HttpRequestHelper::delete( $localInbucketUrl . "/api/v1/mailbox/" . $mailBox, $xRequestId diff --git a/tests/acceptance/TestHelpers/GraphHelper.php b/tests/acceptance/TestHelpers/GraphHelper.php index 21aa08e0ace..acde3dca492 100644 --- a/tests/acceptance/TestHelpers/GraphHelper.php +++ b/tests/acceptance/TestHelpers/GraphHelper.php @@ -110,7 +110,8 @@ public static function getFileIdRegex(): string { * @return string */ public static function getShareIdRegex(): string { - return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex(); + return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex() . '!' + . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex() . ':' . self::getUUIDv4Regex(); } /** @@ -1387,7 +1388,11 @@ public static function getUsersOfTwoGroups( string $password, array $groupIdArray ): ResponseInterface { - $url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') " . "and memberOf/any(m:m/id eq '$groupIdArray[1]')"); + $url = self::getFullUrl( + $baseUrl, + 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$groupIdArray[0]') " + . "and memberOf/any(m:m/id eq '$groupIdArray[1]')" + ); return HttpRequestHelper::get( $url, $xRequestId, @@ -1416,7 +1421,11 @@ public static function getUsersFromOneOrOtherGroup( string $firstGroup, string $secondGroup ): ResponseInterface { - $url = self::getFullUrl($baseUrl, 'users' . '?$filter=memberOf/any(m:m/id ' . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')"); + $url = self::getFullUrl( + $baseUrl, + 'users' . '?$filter=memberOf/any(m:m/id ' + . "eq '$firstGroup') " . "or memberOf/any(m:m/id eq '$secondGroup')" + ); return HttpRequestHelper::get( $url, $xRequestId, @@ -1472,7 +1481,11 @@ public static function getUsersWithFilterRolesAssignmentAndMemberOf( string $roleId, string $groupId ): ResponseInterface { - $url = self::getFullUrl($baseUrl, 'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId ' . "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')"); + $url = self::getFullUrl( + $baseUrl, + 'users' . '?$filter=appRoleAssignments/any(m:m/appRoleId ' + . "eq '$roleId') " . "and memberOf/any(m:m/id eq '$groupId')" + ); return HttpRequestHelper::get( $url, $xRequestId, @@ -1669,7 +1682,15 @@ public static function switchSystemLanguage( ): ResponseInterface { $fullUrl = self::getFullUrl($baseUrl, 'me'); $payload['preferredLanguage'] = $language; - return HttpRequestHelper::sendRequest($fullUrl, $xRequestId, 'PATCH', $user, $password, null, \json_encode($payload)); + return HttpRequestHelper::sendRequest( + $fullUrl, + $xRequestId, + 'PATCH', + $user, + $password, + null, + \json_encode($payload) + ); } /** @@ -1810,7 +1831,13 @@ public static function sendSharingInvitation( ?string $expirationDateTime ): ResponseInterface { $url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/items/$itemId/invite"); - $body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime); + $body = self::createShareInviteBody( + $shareeIds, + $shareTypes, + $permissionsRole, + $permissionsAction, + $expirationDateTime + ); return HttpRequestHelper::post( $url, $xRequestId, @@ -2052,7 +2079,7 @@ public static function disableShareSync( string $password, string $itemId, string $shareSpaceId - ):ResponseInterface { + ): ResponseInterface { $url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId"); return HttpRequestHelper::delete( $url, @@ -2083,7 +2110,7 @@ public static function hideOrUnhideShare( string $itemId, string $shareSpaceId, array $body - ):ResponseInterface { + ): ResponseInterface { $url = self::getBetaFullUrl($baseUrl, "drives/$shareSpaceId/items/$itemId"); return HttpRequestHelper::sendRequest( $url, @@ -2186,7 +2213,13 @@ public static function sendSharingInvitationForDrive( ?string $expirationDateTime ): ResponseInterface { $url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/invite"); - $body = self::createShareInviteBody($shareeIds, $shareTypes, $permissionsRole, $permissionsAction, $expirationDateTime); + $body = self::createShareInviteBody( + $shareeIds, + $shareTypes, + $permissionsRole, + $permissionsAction, + $expirationDateTime + ); return HttpRequestHelper::post( $url, diff --git a/tests/acceptance/TestHelpers/HttpRequestHelper.php b/tests/acceptance/TestHelpers/HttpRequestHelper.php index 21fa4f3024f..d6b42c5f5b0 100644 --- a/tests/acceptance/TestHelpers/HttpRequestHelper.php +++ b/tests/acceptance/TestHelpers/HttpRequestHelper.php @@ -55,7 +55,7 @@ class HttpRequestHelper { * * @return int */ - public static function numRetriesOnHttpTooEarly():int { + public static function numRetriesOnHttpTooEarly(): int { // Currently reva and oCIS may return HTTP_TOO_EARLY // So try up to 10 times before giving up. return 10; @@ -93,7 +93,7 @@ public static function sendRequestOnce( bool $stream = false, ?int $timeout = 0, ?Client $client = null - ):ResponseInterface { + ): ResponseInterface { if ($client === null) { $client = self::createClient( $user, @@ -196,7 +196,7 @@ public static function sendRequest( ?int $timeout = 0, ?Client $client = null, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { if ((\getenv('DEBUG_ACCEPTANCE_RESPONSES') !== false) || (\getenv('DEBUG_ACCEPTANCE_API_CALLS') !== false)) { $debugResponses = true; } else { @@ -222,7 +222,10 @@ public static function sendRequest( $client ); - if ($response->getStatusCode() >= 400 && $response->getStatusCode() !== self::HTTP_TOO_EARLY && $response->getStatusCode() !== self::HTTP_CONFLICT) { + if ($response->getStatusCode() >= 400 + && $response->getStatusCode() !== self::HTTP_TOO_EARLY + && $response->getStatusCode() !== self::HTTP_CONFLICT + ) { $sendExceptionHappened = true; } @@ -261,7 +264,7 @@ public static function sendRequest( * * @return void */ - private static function debugRequest(?RequestInterface $request, ?string $user, ?string $password):void { + private static function debugRequest(?RequestInterface $request, ?string $user, ?string $password): void { print("### AUTH: $user:$password\n"); print("### REQUEST: " . $request->getMethod() . " " . $request->getUri() . "\n"); self::printHeaders($request->getHeaders()); @@ -276,7 +279,7 @@ private static function debugRequest(?RequestInterface $request, ?string $user, * * @return void */ - private static function debugResponse(?ResponseInterface $response):void { + private static function debugResponse(?ResponseInterface $response): void { print("### RESPONSE\n"); print("Status: " . $response->getStatusCode() . "\n"); self::printHeaders($response->getHeaders()); @@ -291,7 +294,7 @@ private static function debugResponse(?ResponseInterface $response):void { * * @return void */ - private static function printHeaders(?array $headers):void { + private static function printHeaders(?array $headers): void { if ($headers) { print("Headers:\n"); foreach ($headers as $header => $value) { @@ -313,7 +316,7 @@ private static function printHeaders(?array $headers):void { * * @return void */ - private static function printBody(?StreamInterface $body):void { + private static function printBody(?StreamInterface $body): void { print("Body:\n"); \var_dump($body->getContents()); // Rewind the stream so that later code can read from the start. @@ -333,7 +336,7 @@ private static function printBody(?StreamInterface $body):void { public static function sendBatchRequest( ?array $requests, ?Client $client - ):array { + ): array { return Pool::batch($client, $requests); } @@ -358,7 +361,7 @@ public static function createClient( ?CookieJar $cookies = null, ?bool $stream = false, ?int $timeout = 0 - ):Client { + ): Client { $options = []; if ($user !== null) { $options['auth'] = [$user, $password]; @@ -396,7 +399,7 @@ public static function createRequest( ?string $method = 'GET', ?array $headers = null, $body = null - ):RequestInterface { + ): RequestInterface { if ($headers === null) { $headers = []; } @@ -449,7 +452,7 @@ public static function get( ?array $config = null, ?CookieJar $cookies = null, ?bool $stream = false - ):ResponseInterface { + ): ResponseInterface { return self::sendRequest( $url, $xRequestId, @@ -491,7 +494,7 @@ public static function post( ?array $config = null, ?CookieJar $cookies = null, ?bool $stream = false - ):ResponseInterface { + ): ResponseInterface { return self::sendRequest( $url, $xRequestId, @@ -533,7 +536,7 @@ public static function put( ?array $config = null, ?CookieJar $cookies = null, ?bool $stream = false - ):ResponseInterface { + ): ResponseInterface { return self::sendRequest( $url, $xRequestId, @@ -576,7 +579,7 @@ public static function delete( ?array $config = null, ?CookieJar $cookies = null, ?bool $stream = false - ):ResponseInterface { + ): ResponseInterface { return self::sendRequest( $url, $xRequestId, @@ -605,7 +608,7 @@ public static function delete( * @return SimpleXMLElement * @throws Exception */ - public static function getResponseXml(ResponseInterface $response, ?string $exceptionText = ''):SimpleXMLElement { + public static function getResponseXml(ResponseInterface $response, ?string $exceptionText = ''): SimpleXMLElement { // rewind just to make sure we can reparse it in case it was parsed already... $response->getBody()->rewind(); $contents = $response->getBody()->getContents(); @@ -647,7 +650,7 @@ public static function getResponseXml(ResponseInterface $response, ?string $exce * * @return array */ - public static function parseResponseAsXml(ResponseInterface $response):array { + public static function parseResponseAsXml(ResponseInterface $response): array { // rewind so that we can reparse it if it was parsed already $response->getBody()->rewind(); $body = $response->getBody()->getContents(); diff --git a/tests/acceptance/TestHelpers/OcisConfigHelper.php b/tests/acceptance/TestHelpers/OcisConfigHelper.php index 70e49b01458..5d3ac479af3 100644 --- a/tests/acceptance/TestHelpers/OcisConfigHelper.php +++ b/tests/acceptance/TestHelpers/OcisConfigHelper.php @@ -56,7 +56,11 @@ public static function sendRequest( try { $response = $client->send($request); } catch (ConnectException $e) { - throw new \Error("Cannot connect to the ociswrapper at the moment, make sure that ociswrapper is running before proceeding with the test run.\n" . $e->getMessage()); + throw new \Error( + "Cannot connect to the ociswrapper at the moment," + . "make sure that ociswrapper is running before proceeding with the test run.\n" + . $e->getMessage() + ); } catch (GuzzleException $ex) { $response = $ex->getResponse(); diff --git a/tests/acceptance/TestHelpers/OcisHelper.php b/tests/acceptance/TestHelpers/OcisHelper.php index c16a4e2638d..ff75a2c97fa 100644 --- a/tests/acceptance/TestHelpers/OcisHelper.php +++ b/tests/acceptance/TestHelpers/OcisHelper.php @@ -87,7 +87,7 @@ public static function getCollaborationServiceUrl(): string { /** * @return bool */ - public static function isTestingOnReva():bool { + public static function isTestingOnReva(): bool { return (\getenv("TEST_REVA") === "true"); } @@ -106,7 +106,7 @@ public static function getDeleteUserDataCommand() { * @return string * @throws Exception */ - public static function getStorageDriver():string { + public static function getStorageDriver(): string { $storageDriver = (\getenv("STORAGE_DRIVER")); if ($storageDriver === false) { return StorageDriver::OWNCLOUD; @@ -166,7 +166,7 @@ public static function deleteRevaUserData(?array $users = []): void { * * @return void */ - public static function recurseCopy(?string $source, ?string $destination):void { + public static function recurseCopy(?string $source, ?string $destination): void { $dir = \opendir($source); @\mkdir($destination); while (($file = \readdir($dir)) !== false) { @@ -184,7 +184,7 @@ public static function recurseCopy(?string $source, ?string $destination):void { /** * @return int */ - public static function getLdapPort():int { + public static function getLdapPort(): int { $port = \getenv("REVA_LDAP_PORT"); return $port ? (int)$port : 636; } @@ -192,7 +192,7 @@ public static function getLdapPort():int { /** * @return bool */ - public static function useSsl():bool { + public static function useSsl(): bool { $useSsl = \getenv("REVA_LDAP_USESSL"); if ($useSsl === false) { return (self::getLdapPort() === 636); @@ -204,7 +204,7 @@ public static function useSsl():bool { /** * @return string */ - public static function getBaseDN():string { + public static function getBaseDN(): string { $dn = \getenv("REVA_LDAP_BASE_DN"); return $dn ?: "dc=owncloud,dc=com"; } @@ -212,7 +212,7 @@ public static function getBaseDN():string { /** * @return string */ - public static function getGroupsOU():string { + public static function getGroupsOU(): string { $ou = \getenv("REVA_LDAP_GROUPS_OU"); return $ou ?: "TestGroups"; } @@ -220,7 +220,7 @@ public static function getGroupsOU():string { /** * @return string */ - public static function getUsersOU():string { + public static function getUsersOU(): string { $ou = \getenv("REVA_LDAP_USERS_OU"); return $ou ?: "TestUsers"; } @@ -228,14 +228,14 @@ public static function getUsersOU():string { /** * @return string */ - public static function getGroupSchema():string { + public static function getGroupSchema(): string { $schema = \getenv("REVA_LDAP_GROUP_SCHEMA"); return $schema ?: "rfc2307"; } /** * @return string */ - public static function getHostname():string { + public static function getHostname(): string { $hostname = \getenv("REVA_LDAP_HOSTNAME"); return $hostname ?: "localhost"; } @@ -243,7 +243,7 @@ public static function getHostname():string { /** * @return string */ - public static function getBindDN():string { + public static function getBindDN(): string { $dn = \getenv("REVA_LDAP_BIND_DN"); return $dn ?: "cn=admin,dc=owncloud,dc=com"; } @@ -251,7 +251,7 @@ public static function getBindDN():string { /** * @return string */ - public static function getBindPassword():string { + public static function getBindPassword(): string { $pw = \getenv("REVA_LDAP_BIND_PASSWORD"); return $pw ?: ""; } @@ -259,7 +259,7 @@ public static function getBindPassword():string { /** * @return string */ - private static function getOcisRevaDataRoot():string { + private static function getOcisRevaDataRoot(): string { $root = \getenv("OCIS_REVA_DATA_ROOT"); if ($root === false || $root === "") { $root = "/var/tmp/ocis/owncloud/"; @@ -275,7 +275,7 @@ private static function getOcisRevaDataRoot():string { * * @return bool */ - private static function recurseRmdir(?string $dir):bool { + private static function recurseRmdir(?string $dir): bool { if (\file_exists($dir) === true) { $files = \array_diff(\scandir($dir), ['.', '..']); foreach ($files as $file) { @@ -307,7 +307,7 @@ public static function createEOSStorageHome( ?string $user, ?string $password, ?string $xRequestId = '' - ):void { + ): void { HttpRequestHelper::get( $baseUrl . "/ocs/v2.php/apps/notifications/api/v1/notifications", $xRequestId, diff --git a/tests/acceptance/TestHelpers/OcsApiHelper.php b/tests/acceptance/TestHelpers/OcsApiHelper.php index 27ba2d1d1eb..eea8af284fd 100644 --- a/tests/acceptance/TestHelpers/OcsApiHelper.php +++ b/tests/acceptance/TestHelpers/OcsApiHelper.php @@ -56,7 +56,7 @@ public static function sendRequest( $body = [], ?int $ocsApiVersion = 2, ?array $headers = [] - ):ResponseInterface { + ): ResponseInterface { $fullUrl = $baseUrl; if (\substr($fullUrl, -1) !== '/') { $fullUrl .= '/'; @@ -86,7 +86,7 @@ public static function createOcsRequest( $body = [], ?int $ocsApiVersion = 2, ?array $headers = [] - ):RequestInterface { + ): RequestInterface { $fullUrl = $baseUrl; if (\substr($fullUrl, -1) !== '/') { $fullUrl .= '/'; diff --git a/tests/acceptance/TestHelpers/SettingsHelper.php b/tests/acceptance/TestHelpers/SettingsHelper.php index d6a31328b01..3f53dd13321 100644 --- a/tests/acceptance/TestHelpers/SettingsHelper.php +++ b/tests/acceptance/TestHelpers/SettingsHelper.php @@ -55,7 +55,13 @@ public static function buildFullUrl(string $baseUrl, string $path): string { * @throws GuzzleException * @throws Exception */ - public static function getBundlesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface { + public static function getBundlesList( + string $baseUrl, + string $user, + string $password, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "bundles-list"); return HttpRequestHelper::post( $fullUrl, @@ -79,7 +85,13 @@ public static function getBundlesList(string $baseUrl, string $user, string $pas * @throws GuzzleException * @throws Exception */ - public static function getBundleByName(string $baseUrl, string $user, string $password, string $bundleName, string $xRequestId): array { + public static function getBundleByName( + string $baseUrl, + string $user, + string $password, + string $bundleName, + string $xRequestId + ): array { $response = self::getBundlesList($baseUrl, $user, $password, $xRequestId); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get bundles list"); @@ -104,7 +116,13 @@ public static function getBundleByName(string $baseUrl, string $user, string $pa * @throws GuzzleException * @throws Exception */ - public static function getRolesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface { + public static function getRolesList( + string $baseUrl, + string $user, + string $password, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "roles-list"); return HttpRequestHelper::post( $fullUrl, @@ -130,7 +148,15 @@ public static function getRolesList(string $baseUrl, string $user, string $passw * @throws GuzzleException * @throws Exception */ - public static function assignRoleToUser(string $baseUrl, string $user, string $password, string $assigneeId, string $roleId, string $xRequestId, array $headers = []): ResponseInterface { + public static function assignRoleToUser( + string $baseUrl, + string $user, + string $password, + string $assigneeId, + string $roleId, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "assignments-add"); $body = json_encode(["account_uuid" => $assigneeId, "role_id" => $roleId], JSON_THROW_ON_ERROR); return HttpRequestHelper::post( @@ -156,7 +182,14 @@ public static function assignRoleToUser(string $baseUrl, string $user, string $p * @throws GuzzleException * @throws Exception */ - public static function getAssignmentsList(string $baseUrl, string $user, string $password, string $userId, string $xRequestId, array $headers = []): ResponseInterface { + public static function getAssignmentsList( + string $baseUrl, + string $user, + string $password, + string $userId, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "assignments-list"); $body = json_encode(["account_uuid" => $userId], JSON_THROW_ON_ERROR); return HttpRequestHelper::post( @@ -181,7 +214,13 @@ public static function getAssignmentsList(string $baseUrl, string $user, string * @throws GuzzleException * @throws Exception */ - public static function getValuesList(string $baseUrl, string $user, string $password, string $xRequestId, array $headers = []): ResponseInterface { + public static function getValuesList( + string $baseUrl, + string $user, + string $password, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "values-list"); $body = json_encode(["account_uuid" => "me"], JSON_THROW_ON_ERROR); return HttpRequestHelper::post( @@ -205,7 +244,12 @@ public static function getValuesList(string $baseUrl, string $user, string $pass * @throws GuzzleException * @throws Exception */ - public static function getAutoAcceptSharesSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): bool { + public static function getAutoAcceptSharesSettingValue( + string $baseUrl, + string $user, + string $password, + string $xRequestId + ): bool { $response = self::getValuesList($baseUrl, $user, $password, $xRequestId); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list"); @@ -235,7 +279,12 @@ public static function getAutoAcceptSharesSettingValue(string $baseUrl, string $ * @throws GuzzleException * @throws Exception */ - public static function getLanguageSettingValue(string $baseUrl, string $user, string $password, string $xRequestId): string { + public static function getLanguageSettingValue( + string $baseUrl, + string $user, + string $password, + string $xRequestId + ): string { $response = self::getValuesList($baseUrl, $user, $password, $xRequestId); Assert::assertEquals(201, $response->getStatusCode(), "Failed to get values list"); @@ -267,7 +316,14 @@ public static function getLanguageSettingValue(string $baseUrl, string $user, st * @throws GuzzleException * @throws Exception */ - public static function updateSettings(string $baseUrl, string $user, string $password, string $body, string $xRequestId, array $headers = []): ResponseInterface { + public static function updateSettings( + string $baseUrl, + string $user, + string $password, + string $body, + string $xRequestId, + array $headers = [] + ): ResponseInterface { $fullUrl = self::buildFullUrl($baseUrl, "values-save"); return HttpRequestHelper::post( $fullUrl, diff --git a/tests/acceptance/TestHelpers/SetupHelper.php b/tests/acceptance/TestHelpers/SetupHelper.php index d6652040158..e927e7e771f 100644 --- a/tests/acceptance/TestHelpers/SetupHelper.php +++ b/tests/acceptance/TestHelpers/SetupHelper.php @@ -43,7 +43,7 @@ class SetupHelper extends \PHPUnit\Framework\Assert { * * @return array of suite context parameters */ - public static function getSuiteParameters(HookScope $scope):array { + public static function getSuiteParameters(HookScope $scope): array { return $scope->getEnvironment()->getSuite() ->getSettings() ['context'] ['parameters']; } @@ -90,7 +90,7 @@ public static function getSysInfo( ?string $adminUsername, ?string $adminPassword, ?string $xRequestId = '' - ):SimpleXMLElement { + ): SimpleXMLElement { $result = OcsApiHelper::sendRequest( $baseUrl, $adminUsername, @@ -122,7 +122,7 @@ public static function getServerRoot( ?string $adminUsername, ?string $adminPassword, ?string $xRequestId = '' - ):string { + ): string { $sysInfo = self::getSysInfo( $baseUrl, $adminUsername, @@ -141,7 +141,7 @@ public static function getServerRoot( * @return string * @throws Exception */ - private static function checkAdminUsername(?string $adminUsername, ?string $callerName):?string { + private static function checkAdminUsername(?string $adminUsername, ?string $callerName): ?string { if (self::$adminUsername === null && $adminUsername === null ) { @@ -162,7 +162,7 @@ private static function checkAdminUsername(?string $adminUsername, ?string $call * @return string * @throws Exception */ - private static function checkAdminPassword(?string $adminPassword, ?string $callerName):string { + private static function checkAdminPassword(?string $adminPassword, ?string $callerName): string { if (self::$adminPassword === null && $adminPassword === null ) { @@ -183,7 +183,7 @@ private static function checkAdminPassword(?string $adminPassword, ?string $call * @return string * @throws Exception */ - private static function checkBaseUrl(?string $baseUrl, ?string $callerName):?string { + private static function checkBaseUrl(?string $baseUrl, ?string $callerName): ?string { if (self::$baseUrl === null && $baseUrl === null ) { @@ -215,7 +215,7 @@ public static function mkDirOnServer( ?string $baseUrl = null, ?string $adminUsername = null, ?string $adminPassword = null - ):void { + ): void { $baseUrl = self::checkBaseUrl($baseUrl, "mkDirOnServer"); $adminUsername = self::checkAdminUsername($adminUsername, "mkDirOnServer"); $adminPassword = self::checkAdminPassword($adminPassword, "mkDirOnServer"); @@ -254,7 +254,7 @@ public static function rmDirOnServer( ?string $baseUrl = null, ?string $adminUsername = null, ?string $adminPassword = null - ):void { + ): void { $baseUrl = self::checkBaseUrl($baseUrl, "rmDirOnServer"); $adminUsername = self::checkAdminUsername($adminUsername, "rmDirOnServer"); $adminPassword = self::checkAdminPassword($adminPassword, "rmDirOnServer"); @@ -295,7 +295,7 @@ public static function createFileOnServer( ?string $baseUrl = null, ?string $adminUsername = null, ?string $adminPassword = null - ):void { + ): void { $baseUrl = self::checkBaseUrl($baseUrl, "createFileOnServer"); $adminUsername = self::checkAdminUsername($adminUsername, "createFileOnServer"); $adminPassword = self::checkAdminPassword($adminPassword, "createFileOnServer"); @@ -337,7 +337,7 @@ public static function deleteFileOnServer( ?string $baseUrl = null, ?string $adminUsername = null, ?string $adminPassword = null - ):void { + ): void { $baseUrl = self::checkBaseUrl($baseUrl, "deleteFileOnServer"); $adminUsername = self::checkAdminUsername($adminUsername, "deleteFileOnServer"); $adminPassword = self::checkAdminPassword($adminPassword, "deleteFileOnServer"); @@ -377,7 +377,7 @@ public static function readFileFromServer( ?string $baseUrl = null, ?string $adminUsername = null, ?string $adminPassword = null - ):string { + ): string { $baseUrl = self::checkBaseUrl($baseUrl, "readFile"); $adminUsername = self::checkAdminUsername( $adminUsername, diff --git a/tests/acceptance/TestHelpers/SharingHelper.php b/tests/acceptance/TestHelpers/SharingHelper.php index 07a2e74f53a..67fe337cfa4 100644 --- a/tests/acceptance/TestHelpers/SharingHelper.php +++ b/tests/acceptance/TestHelpers/SharingHelper.php @@ -192,7 +192,7 @@ public static function createShare( * @throws InvalidArgumentException * */ - public static function getPermissionSum($permissions):int { + public static function getPermissionSum($permissions): int { if (\is_numeric($permissions)) { // Allow any permission number so that test scenarios can // specifically test invalid permission values @@ -230,7 +230,7 @@ public static function getPermissionSum($permissions):int { * @throws InvalidArgumentException * */ - public static function getShareType($shareType):int { + public static function getShareType($shareType): int { if (\array_key_exists($shareType, self::SHARE_TYPES)) { return self::SHARE_TYPES[$shareType]; } else { @@ -259,7 +259,7 @@ public static function getShareType($shareType):int { public static function getLastShareIdFromResponse( SimpleXMLElement $responseXmlObject, string $errorMessage = "cannot find share id in response" - ):string { + ): string { $xmlPart = $responseXmlObject->xpath("//data/element[last()]/id"); if (!\is_array($xmlPart) || (\count($xmlPart) === 0)) { diff --git a/tests/acceptance/TestHelpers/UploadHelper.php b/tests/acceptance/TestHelpers/UploadHelper.php index e85319fc59a..fe3577ff7e7 100644 --- a/tests/acceptance/TestHelpers/UploadHelper.php +++ b/tests/acceptance/TestHelpers/UploadHelper.php @@ -138,7 +138,7 @@ public static function upload( * * @return array $string */ - public static function chunkFile(?string $file, ?int $noOfChunks = 1):array { + public static function chunkFile(?string $file, ?int $noOfChunks = 1): array { $size = \filesize($file); $chunkSize = \ceil($size / $noOfChunks); $chunks = []; @@ -162,7 +162,7 @@ public static function chunkFile(?string $file, ?int $noOfChunks = 1):array { * * @return void */ - public static function createFileSpecificSize(?string $name, ?int $size):void { + public static function createFileSpecificSize(?string $name, ?int $size): void { if (\file_exists($name)) { \unlink($name); } @@ -190,7 +190,7 @@ public static function createFileSpecificSize(?string $name, ?int $size):void { * * @return void */ - public static function createFileWithText(?string $name, ?string $text):void { + public static function createFileWithText(?string $name, ?string $text): void { $file = \fopen($name, 'w'); \fwrite($file, $text); \fclose($file); @@ -207,7 +207,7 @@ public static function createFileWithText(?string $name, ?string $text):void { * * @return string */ - public static function getUploadFilesDir(?string $name):string { + public static function getUploadFilesDir(?string $name): string { return \getenv("FILES_FOR_UPLOAD") . $name; } } diff --git a/tests/acceptance/TestHelpers/UserHelper.php b/tests/acceptance/TestHelpers/UserHelper.php index e38e05981a7..a35a5b73c88 100644 --- a/tests/acceptance/TestHelpers/UserHelper.php +++ b/tests/acceptance/TestHelpers/UserHelper.php @@ -56,7 +56,7 @@ public static function editUser( string $adminPassword, string $xRequestId = '', ?int $ocsApiVersion = 2 - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -90,7 +90,7 @@ public static function editUserBatch( ?string $adminPassword, ?string $xRequestId = '', ?int $ocsApiVersion = 2 - ):array { + ): array { $requests = []; $client = HttpRequestHelper::createClient( $adminUser, @@ -143,7 +143,7 @@ public static function getUser( ?string $adminPassword, ?string $xRequestId = '', ?int $ocsApiVersion = 2 - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -175,7 +175,7 @@ public static function deleteUser( ?string $adminPassword, ?string $xRequestId = '', ?int $ocsApiVersion = 2 - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -209,7 +209,7 @@ public static function addUserToGroup( ?string $adminPassword, ?string $xRequestId = '', ?int $ocsApiVersion = 2 - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -243,7 +243,7 @@ public static function removeUserFromGroup( ?string $adminPassword, ?string $xRequestId, ?int $ocsApiVersion = 2 - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -273,7 +273,7 @@ public static function getGroups( ?string $adminPassword, ?string $xRequestId = '', ?string $search ="" - ):ResponseInterface { + ): ResponseInterface { return OcsApiHelper::sendRequest( $baseUrl, $adminUser, @@ -301,7 +301,7 @@ public static function getGroupsAsArray( ?string $adminPassword, ?string $xRequestId = '', ?string $search = "" - ):array { + ): array { $result = self::getGroups( $baseUrl, $adminUser, diff --git a/tests/acceptance/TestHelpers/WebDavHelper.php b/tests/acceptance/TestHelpers/WebDavHelper.php index 4297e18feb5..ac9c2519827 100644 --- a/tests/acceptance/TestHelpers/WebDavHelper.php +++ b/tests/acceptance/TestHelpers/WebDavHelper.php @@ -86,7 +86,7 @@ public static function isDAVRequest(string $url): bool { */ public static function removeSpaceIdReferenceForUser( ?string $user - ):void { + ): void { if (\array_key_exists($user, self::$spacesIdRef)) { unset(self::$spacesIdRef[$user]); } @@ -245,7 +245,7 @@ public static function propfind( ?int $davPathVersionToUse = self::DAV_VERSION_NEW, ?string $doDavRequestAsUser = null, ?array $headers = [] - ):ResponseInterface { + ): ResponseInterface { $body = self::getBodyForPropfind($properties); $folderDepth = (string) $folderDepth; if ($folderDepth !== '0' && $folderDepth !== '1' && $folderDepth !== 'infinity') { @@ -307,7 +307,7 @@ public static function proppatch( ?int $davPathVersionToUse = self::DAV_VERSION_NEW, ?string $type="files", ?string $spaceId = null, - ):ResponseInterface { + ): ResponseInterface { if ($namespaceString !== null) { $ns = self::parseNamespace($namespaceString); $propertyBody = "<$ns->prefix:$propertyName" . @@ -348,7 +348,7 @@ public static function proppatch( * * @return array */ - public static function getPropertyWithNamespaceInfo(string $namespaceString = "", string $property = ""):array { + public static function getPropertyWithNamespaceInfo(string $namespaceString = "", string $property = ""): array { $namespace = ""; $namespacePrefix = ""; if (\is_int($namespaceString)) { @@ -396,7 +396,7 @@ public static function proppatchWithMultipleProps( ?int $davPathVersion = null, ?string $namespaceString = null, ?string $type="files" - ):ResponseInterface { + ): ResponseInterface { $propertyBody = ""; foreach ($propertiesArray as $propertyArray) { $property = $propertyArray["propertyName"]; @@ -466,7 +466,7 @@ public static function listFolder( ?array $properties = null, ?string $type = "files", ?int $davPathVersionToUse = self::DAV_VERSION_NEW - ):ResponseInterface { + ): ResponseInterface { if (!$properties) { $properties = [ 'd:getetag', 'd:resourcetype' @@ -493,7 +493,7 @@ public static function listFolder( * @return string * @throws Exception */ - public static function generateUUIDv4():string { + public static function generateUUIDv4(): string { // generate 16 bytes (128 bits) of random data or use the data passed into the function. $data = random_bytes(16); \assert(\strlen($data) == 16); @@ -516,7 +516,12 @@ public static function generateUUIDv4():string { * @throws GuzzleException * @throws Exception */ - public static function getPersonalSpaceIdForUser(string $baseUrl, string $user, string $password, string $xRequestId):string { + public static function getPersonalSpaceIdForUser( + string $baseUrl, + string $user, + string $password, + string $xRequestId + ): string { if (\array_key_exists($user, self::$spacesIdRef) && \array_key_exists("personal", self::$spacesIdRef[$user])) { return self::$spacesIdRef[$user]["personal"]; } @@ -546,14 +551,21 @@ public static function getPersonalSpaceIdForUser(string $baseUrl, string $user, $user, $password ); - Assert::assertEquals(207, $response->getStatusCode(), "PROPFIND for user '$user' failed so the personal space id cannot be discovered"); + Assert::assertEquals( + 207, + $response->getStatusCode(), + "PROPFIND for user '$user' failed so the personal space id cannot be discovered" + ); $responseXmlObject = HttpRequestHelper::getResponseXml( $response, __METHOD__ ); $xmlPart = $responseXmlObject->xpath("/d:multistatus/d:response[1]/d:propstat/d:prop/oc:spaceid"); - Assert::assertNotEmpty($xmlPart, "The 'oc:spaceid' for user '$user' was not found in the PROPFIND response"); + Assert::assertNotEmpty( + $xmlPart, + "The 'oc:spaceid' for user '$user' was not found in the PROPFIND response" + ); $personalSpaceId = $xmlPart[0]->__toString(); } @@ -577,7 +589,12 @@ public static function getPersonalSpaceIdForUser(string $baseUrl, string $user, * @return string * @throws Exception|GuzzleException */ - public static function getPersonalSpaceIdForUserOrFakeIfNotFound(string $baseUrl, string $user, string $password, string $xRequestId):string { + public static function getPersonalSpaceIdForUserOrFakeIfNotFound( + string $baseUrl, + string $user, + string $password, + string $xRequestId + ): string { if (\str_starts_with($user, "non-exist") || \str_starts_with($user, "nonexist")) { return self::generateUUIDv4(); } @@ -641,7 +658,7 @@ public static function makeDavRequest( ?array $urlParameter = [], ?string $doDavRequestAsUser = null, ?bool $isGivenStep = false, - ):ResponseInterface { + ): ResponseInterface { $baseUrl = self::sanitizeUrl($baseUrl, true); // We need to manipulate and use path as a string. @@ -651,7 +668,9 @@ public static function makeDavRequest( } // get space id if testing with spaces dav - if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["public-files", "versions"])) { + if ($spaceId === null && $davPathVersionToUse === self::DAV_VERSION_SPACES + && !\in_array($type, ["public-files", "versions"]) + ) { $path = \ltrim($path, "/"); if (\str_starts_with($path, "Shares/")) { $spaceId = GraphHelper::SHARES_SPACE_ID; @@ -667,7 +686,9 @@ public static function makeDavRequest( } $suffixPath = $user; - if ($davPathVersionToUse === self::DAV_VERSION_SPACES && !\in_array($type, ["archive", "versions", "public-files"])) { + if ($davPathVersionToUse === self::DAV_VERSION_SPACES + && !\in_array($type, ["archive", "versions", "public-files"]) + ) { $suffixPath = $spaceId; } elseif ($type === "versions") { // $path is file-id in case of versions @@ -751,7 +772,7 @@ public static function getDavPath( int $davPathVersion, ?string $userOrItemIdOrSpaceIdOrToken = null, ?string $type = "files" - ):string { + ): string { switch ($type) { case 'archive': return self::prefixRemotePhp("dav/archive/$userOrItemIdOrSpaceIdOrToken/files"); @@ -807,7 +828,7 @@ public static function getDavPath( * * @return string */ - public static function sanitizeUrl(?string $url, ?bool $trailingSlash = false):string { + public static function sanitizeUrl(?string $url, ?bool $trailingSlash = false): string { if ($trailingSlash === true) { $url = $url . "/"; } else { @@ -834,7 +855,7 @@ public static function getMtimeOfFileInPublicLinkShare( ?string $token, ?string $xRequestId = '', ?int $davVersionToUse = self::DAV_VERSION_NEW - ):string { + ): string { $response = self::propfind( $baseUrl, null, @@ -879,7 +900,7 @@ public static function getMtimeOfResource( ?string $xRequestId = '', ?int $davPathVersionToUse = self::DAV_VERSION_NEW, ?string $spaceId = null, - ):string { + ): string { $response = self::propfind( $baseUrl, $user, @@ -900,7 +921,9 @@ public static function getMtimeOfResource( Assert::assertArrayHasKey( 0, $xmlPart, - __METHOD__ . " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: " . json_encode($xmlPart) + __METHOD__ + . " XML part does not have key 0. Expected a value at index 0 of 'xmlPart' but, found: " + . json_encode($xmlPart) ); $mtime = new DateTime($xmlPart[0]->__toString()); return $mtime->format('U'); diff --git a/tests/acceptance/bootstrap/ArchiverContext.php b/tests/acceptance/bootstrap/ArchiverContext.php index d29f1906809..a5cd7ac9fe7 100644 --- a/tests/acceptance/bootstrap/ArchiverContext.php +++ b/tests/acceptance/bootstrap/ArchiverContext.php @@ -164,7 +164,9 @@ public function userDownloadsTheZipOrTarArchiveOfResourceUsingResourceIdOrPathAn foreach ($headersTable as $row) { $headers[$row['header']] = $row ['value']; } - $this->featureContext->setResponse($this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers)); + $this->featureContext->setResponse( + $this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers) + ); } /** @@ -267,7 +269,7 @@ public function userDownloadsTheArchiveOfTheseItems( * * @throws Exception */ - public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableNode $expectedFiles):void { + public function theDownloadedArchiveShouldContainTheseFiles(string $type, TableNode $expectedFiles): void { $this->featureContext->verifyTableNodeColumns($expectedFiles, ['name', 'content']); $contents = $this->featureContext->getResponse()->getBody()->getContents(); $tempFile = \tempnam(\sys_get_temp_dir(), 'OcAcceptanceTests_'); diff --git a/tests/acceptance/bootstrap/AuthContext.php b/tests/acceptance/bootstrap/AuthContext.php index 72346012c8e..4e0d4ee6c50 100644 --- a/tests/acceptance/bootstrap/AuthContext.php +++ b/tests/acceptance/bootstrap/AuthContext.php @@ -40,7 +40,7 @@ class AuthContext implements Context { * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -141,7 +141,7 @@ public function requestUrlWithBasicAuth( * * @return void */ - public function userRequestsURLWithNoAuth(string $url, string $method):void { + public function userRequestsURLWithNoAuth(string $url, string $method): void { $this->featureContext->setResponse($this->sendRequest($url, $method)); } @@ -156,7 +156,12 @@ public function userRequestsURLWithNoAuth(string $url, string $method):void { * @return void * @throws JsonException */ - public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(string $method, string $body, string $ofUser, TableNode $table): void { + public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser( + string $method, + string $body, + string $ofUser, + TableNode $table + ): void { $ofUser = \strtolower($this->featureContext->getActualUsername($ofUser)); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); foreach ($table->getHash() as $row) { @@ -180,7 +185,11 @@ public function userRequestsEndpointsWithBodyAndNoAuthThenStatusCodeAboutUser(st * @return void * @throws Exception */ - public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(string $method, string $ofUser, TableNode $table): void { + public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser( + string $method, + string $ofUser, + TableNode $table + ): void { $ofUser = \strtolower($this->featureContext->getActualUsername($ofUser)); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); foreach ($table->getHash() as $row) { @@ -203,7 +212,7 @@ public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(string $metho * @return void * @throws Exception */ - public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table):void { + public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['service']); foreach ($table->getHash() as $row) { $this->featureContext->setResponse( @@ -226,7 +235,7 @@ public function userRequestsEndpointsWithNoAuthentication(string $method, TableN * @return void * @throws Exception */ - public function userRequestsEndpointsWithBasicAuth(string $user, string $method, TableNode $table):void { + public function userRequestsEndpointsWithBasicAuth(string $user, string $method, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); foreach ($table->getHash() as $row) { $response = $this->requestUrlWithBasicAuth($user, $row['endpoint'], $method); @@ -253,7 +262,7 @@ public function theUserRequestsTheseEndpointsToGetOrSetPropertyAboutUser( string $property, string $ofUser, TableNode $table - ):void { + ): void { $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); foreach ($table->getHash() as $row) { @@ -276,7 +285,7 @@ public function theUserRequestsTheseEndpointsToGetOrSetPropertyAboutUser( * @return void * @throws Exception */ - public function theAdminRequestsTheseEndpointsWithMethod(string $method, TableNode $table):void { + public function theAdminRequestsTheseEndpointsWithMethod(string $method, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); foreach ($table->getHash() as $row) { $response = $this->requestUrlWithBasicAuth( @@ -302,7 +311,7 @@ public function userRequestsURLUsingBasicAuth( string $user, string $url, string $method - ):void { + ): void { $response = $this->requestUrlWithBasicAuth($user, $url, $method); $this->featureContext->setResponse($response); } @@ -318,7 +327,12 @@ public function userRequestsURLUsingBasicAuth( * @return void * @throws Exception */ - public function userRequestsURLWithUsingBasicAuthAndDepthHeader(string $user, string $url, string $method, TableNode $headersTable):void { + public function userRequestsURLWithUsingBasicAuthAndDepthHeader( + string $user, + string $url, + string $method, + TableNode $headersTable + ): void { $user = $this->featureContext->getActualUsername($user); $url = $this->featureContext->substituteInLineCodes( $url, @@ -390,7 +404,7 @@ public function userRequestsTheseEndpointsUsingPasswordAboutUser( string $password, string $ofUser, TableNode $table - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $ofUser = $this->featureContext->getActualUsername($ofUser); $this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['destination']); @@ -407,7 +421,8 @@ public function userRequestsTheseEndpointsUsingPasswordAboutUser( $row['destination'], $ofUser ); - $headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); + $headers['Destination'] = $this->featureContext->getBaseUrl() + . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); } $response = $this->sendRequest( $row['endpoint'], @@ -440,7 +455,7 @@ public function userRequestsTheseEndpointsWithBodyUsingPasswordAboutUser( string $password, string $ofUser, TableNode $table - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $ofUser = $this->featureContext->getActualUsername($ofUser); $this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['destination']); @@ -457,7 +472,8 @@ public function userRequestsTheseEndpointsWithBodyUsingPasswordAboutUser( $row['destination'], $ofUser ); - $headers['Destination'] = $this->featureContext->getBaseUrl() . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); + $headers['Destination'] = $this->featureContext->getBaseUrl() + . "/" . WebdavHelper::prefixRemotePhp(\ltrim($destination, "/")); } $response = $this->sendRequest( $row['endpoint'], @@ -482,7 +498,13 @@ public function userRequestsTheseEndpointsWithBodyUsingPasswordAboutUser( * @return void * @throws Exception */ - public function userRequestsTheseEndpointsIncludingBodyAboutUser(string $user, string $method, string $body, string $ofUser, TableNode $table):void { + public function userRequestsTheseEndpointsIncludingBodyAboutUser( + string $user, + string $method, + string $body, + string $ofUser, + TableNode $table + ): void { $user = $this->featureContext->getActualUsername($user); $ofUser = $this->featureContext->getActualUsername($ofUser); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); @@ -520,7 +542,12 @@ public function userRequestsTheseEndpointsIncludingBodyAboutUser(string $user, s * @return void * @throws Exception */ - public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(string $asUser, string $method, string $ofUser, TableNode $table):void { + public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser( + string $asUser, + string $method, + string $ofUser, + TableNode $table + ): void { $asUser = $this->featureContext->getActualUsername($asUser); $ofUser = $this->featureContext->getActualUsername($ofUser); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); @@ -556,7 +583,13 @@ public function userRequestsTheseEndpointsWithoutBodyUsingThePasswordOfUser(stri * @return void * @throws JsonException */ - public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(string $asUser, string $method, ?string $body, string $ofUser, TableNode $table):void { + public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser( + string $asUser, + string $method, + ?string $body, + string $ofUser, + TableNode $table + ): void { $asUser = $this->featureContext->getActualUsername($asUser); $ofUser = $this->featureContext->getActualUsername($ofUser); $this->featureContext->verifyTableNodeColumns($table, ['endpoint']); @@ -591,7 +624,12 @@ public function userRequestsTheseEndpointsIncludingBodyUsingPasswordOfUser(strin * @return void * @throws Exception */ - public function userRequestsTheseEndpointsAboutUser(string $user, string $method, string $ofUser, TableNode $table):void { + public function userRequestsTheseEndpointsAboutUser( + string $user, + string $method, + string $ofUser, + TableNode $table + ): void { $headers = []; if ($method === 'MOVE' || $method === 'COPY') { $baseUrl = $this->featureContext->getBaseUrl(); @@ -633,7 +671,7 @@ public function userRequestsURLWithoutRetry( string $user, string $endpoint, string $method - ):void { + ): void { $username = $this->featureContext->getActualUsername($user); $endpoint = $this->featureContext->substituteInLineCodes( $endpoint, diff --git a/tests/acceptance/bootstrap/CapabilitiesContext.php b/tests/acceptance/bootstrap/CapabilitiesContext.php index 739c9dee354..8ee6248ec5f 100644 --- a/tests/acceptance/bootstrap/CapabilitiesContext.php +++ b/tests/acceptance/bootstrap/CapabilitiesContext.php @@ -49,7 +49,7 @@ class CapabilitiesContext implements Context { * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -164,7 +164,7 @@ public function theAdministratorGetsCapabilities(): void { * @return void * @throws Exception */ - public function checkVersionMajorMinorMicroResponse():void { + public function checkVersionMajorMinorMicroResponse(): void { $jsonResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); $versionData = $jsonResponse->ocs->data->version; $versionString = (string) $versionData->string; diff --git a/tests/acceptance/bootstrap/ChecksumContext.php b/tests/acceptance/bootstrap/ChecksumContext.php index 18242e7e794..50a6d58f791 100644 --- a/tests/acceptance/bootstrap/ChecksumContext.php +++ b/tests/acceptance/bootstrap/ChecksumContext.php @@ -47,7 +47,7 @@ public function uploadFileToWithChecksumUsingTheAPI( string $source, string $destination, string $checksum - ):ResponseInterface { + ): ResponseInterface { $file = \file_get_contents( $this->featureContext->acceptanceTestsDirLocation() . $source ); @@ -75,8 +75,10 @@ public function userUploadsFileToWithChecksumUsingTheAPI( string $source, string $destination, string $checksum - ):void { - $this->featureContext->setResponse($this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum)); + ): void { + $this->featureContext->setResponse( + $this->uploadFileToWithChecksumUsingTheAPI($user, $source, $destination, $checksum) + ); } /** @@ -94,7 +96,7 @@ public function userHasUploadedFileToWithChecksumUsingTheAPI( string $source, string $destination, string $checksum - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $response = $this->uploadFileToWithChecksumUsingTheAPI( $user, @@ -118,7 +120,7 @@ public function uploadFileWithContentAndChecksumToUsingTheAPI( string $content, string $checksum, string $destination - ):ResponseInterface { + ): ResponseInterface { return $this->featureContext->makeDavRequest( $user, 'PUT', @@ -143,7 +145,7 @@ public function userHasUploadedFileWithContentAndChecksumToUsingTheAPI( string $content, string $checksum, string $destination - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $response = $this->uploadFileWithContentAndChecksumToUsingTheAPI($user, $content, $checksum, $destination); $this->featureContext->theHTTPStatusCodeShouldBe(201, '', $response); @@ -157,7 +159,7 @@ public function userHasUploadedFileWithContentAndChecksumToUsingTheAPI( * * @return void */ - public function userRequestsTheChecksumOfViaPropfind(string $user, string $path):void { + public function userRequestsTheChecksumOfViaPropfind(string $user, string $path): void { $this->featureContext->setResponse($this->propfindResourceChecksum($user, $path)); } @@ -168,7 +170,7 @@ public function userRequestsTheChecksumOfViaPropfind(string $user, string $path) * * @return ResponseInterface */ - public function propfindResourceChecksum(string $user, string $path, ?string $spaceId = null) : ResponseInterface { + public function propfindResourceChecksum(string $user, string $path, ?string $spaceId = null): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $body = ' @@ -199,7 +201,7 @@ public function propfindResourceChecksum(string $user, string $path, ?string $sp * @return void * @throws Exception */ - public function theWebdavChecksumShouldMatch(string $expectedChecksum):void { + public function theWebdavChecksumShouldMatch(string $expectedChecksum): void { $bodyContents = $this->featureContext->getResponse()->getBody()->getContents(); $this->validateChecksum($bodyContents, $expectedChecksum); } @@ -214,7 +216,11 @@ public function theWebdavChecksumShouldMatch(string $expectedChecksum):void { * @return void * @throws Exception */ - public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(string $user, string $path, string $expectedChecksum):void { + public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch( + string $user, + string $path, + string $expectedChecksum + ): void { $user = $this->featureContext->getActualUsername($user); $resource = $this->propfindResourceChecksum($user, $path); $bodyContents = $resource->getBody()->getContents(); @@ -226,7 +232,7 @@ public function asUserTheWebdavChecksumOfPathViaPropfindShouldMatch(string $user * * @return void */ - public function validateChecksum(string $bodyContents, string $expectedChecksum):void { + public function validateChecksum(string $bodyContents, string $expectedChecksum): void { $service = new Sabre\Xml\Service(); $parsed = $service->parse($bodyContents); @@ -243,7 +249,8 @@ public function validateChecksum(string $bodyContents, string $expectedChecksum) Assert::assertIsArray( $parsed, - __METHOD__ . " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents + __METHOD__ + . " could not parse response as XML. Expected parsed XML to be an array but found " . $bodyContents ); Assert::assertArrayHasKey( 0, @@ -320,7 +327,7 @@ public function validateChecksum(string $bodyContents, string $expectedChecksum) * @return void * @throws Exception */ - public function theHeaderChecksumShouldMatch(string $expectedChecksum):void { + public function theHeaderChecksumShouldMatch(string $expectedChecksum): void { $headerChecksums = $this->featureContext->getResponse()->getHeader('OC-Checksum'); @@ -360,7 +367,11 @@ public function theHeaderChecksumShouldMatch(string $expectedChecksum):void { * @return void * @throws Exception */ - public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch(string $user, string $fileName, string $expectedChecksum):void { + public function theHeaderChecksumWhenUserDownloadsFileUsingTheWebdavApiShouldMatch( + string $user, + string $fileName, + string $expectedChecksum + ): void { $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName); $headerChecksums = $response->getHeader('OC-Checksum'); @@ -407,7 +418,7 @@ public function uploadChunkFileOfWithToWithChecksum( string $data, string $destination, string $expectedChecksum - ):ResponseInterface { + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $num -= 1; $file = "$destination-chunking-42-$total-$num"; @@ -439,8 +450,15 @@ public function userUploadsChunkFileOfWithToWithChecksum( string $data, string $destination, string $expectedChecksum - ):void { - $response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum); + ): void { + $response = $this->uploadChunkFileOfWithToWithChecksum( + $user, + $num, + $total, + $data, + $destination, + $expectedChecksum + ); $this->featureContext->setResponse($response); } @@ -463,8 +481,15 @@ public function userHasUploadedChunkFileOfWithToWithChecksum( string $data, string $destination, string $expectedChecksum - ):void { - $response = $this->uploadChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $expectedChecksum); + ): void { + $response = $this->uploadChunkFileOfWithToWithChecksum( + $user, + $num, + $total, + $data, + $destination, + $expectedChecksum + ); $this->featureContext->theHTTPStatusCodeShouldBe( [201, 206], '', @@ -482,7 +507,7 @@ public function userHasUploadedChunkFileOfWithToWithChecksum( * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context diff --git a/tests/acceptance/bootstrap/CliContext.php b/tests/acceptance/bootstrap/CliContext.php index 64da475b466..1dae04440c3 100644 --- a/tests/acceptance/bootstrap/CliContext.php +++ b/tests/acceptance/bootstrap/CliContext.php @@ -80,7 +80,11 @@ public function theAdministratorHasStartedTheServer(): void { * * @return void */ - public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $status, string $user, string $password): void { + public function theAdministratorResetsThePasswordOfUserUsingTheCLI( + string $status, + string $user, + string $password + ): void { $command = "idm resetpassword -u $user"; $body = [ "command" => $command, @@ -99,7 +103,7 @@ public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $statu * * @return void */ - public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli():void { + public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli(): void { $path = $this->featureContext->getStorageUsersRoot(); $command = "trash purge-empty-dirs -p $path --dry-run=false"; $body = [ @@ -113,7 +117,7 @@ public function theAdministratorDeletesEmptyTrashbinFoldersUsingTheCli():void { * * @return void */ - public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void { + public function theAdministratorChecksTheBackupConsistencyUsingTheCli(): void { $path = $this->featureContext->getStorageUsersRoot(); $command = "backup consistency -p $path"; $body = [ @@ -121,7 +125,7 @@ public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void { ]; $this->featureContext->setResponse(CliHelper::runCommand($body)); } - + /** * @When the administrator creates app token for user :user with expiration time :expirationTime using the auth-app CLI * @@ -130,7 +134,10 @@ public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void { * * @return void */ - public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void { + public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingTheAuthAppCLI( + string $user, + string $expirationTime + ): void { $user = $this->featureContext->getActualUserName($user); $command = "auth-app create --user-name=$user --expiration=$expirationTime"; $body = [ @@ -147,7 +154,10 @@ public function theAdministratorCreatesAppTokenForUserWithExpirationTimeUsingThe * * @return void */ - public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(string $user, string $expirationTime): void { + public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI( + string $user, + string $expirationTime + ): void { $user = $this->featureContext->getActualUserName($user); $command = "auth-app create --user-name=$user --expiration=$expirationTime"; $body = [ @@ -158,7 +168,11 @@ public function userHasCreatedAppTokenWithExpirationTimeUsingTheAuthAppCLI(strin $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); $jsonResponse = $this->featureContext->getJsonDecodedResponse($response); Assert::assertSame("OK", $jsonResponse["status"]); - Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]); + Assert::assertSame( + 0, + $jsonResponse["exitCode"], + "Expected exit code to be 0, but got " . $jsonResponse["exitCode"] + ); } /** @@ -230,7 +244,7 @@ public function theAdministratorReindexesASpaceUsingTheCli(string $spaceName): v * * @return void */ - public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(string $space):void { + public function theAdministratorRemovesTheVersionsOfFilesInSpaceUsingSpaceId(string $space): void { $path = $this->featureContext->getStorageUsersRoot(); $adminUsername = $this->featureContext->getAdminUsername(); $spaceId = $this->spacesContext->getSpaceIdByName($adminUsername, $space); @@ -253,7 +267,11 @@ public function theCommandShouldBeSuccessful(): void { $jsonResponse = $this->featureContext->getJsonDecodedResponse($response); Assert::assertSame("OK", $jsonResponse["status"]); - Assert::assertSame(0, $jsonResponse["exitCode"], "Expected exit code to be 0, but got " . $jsonResponse["exitCode"]); + Assert::assertSame( + 0, + $jsonResponse["exitCode"], + "Expected exit code to be 0, but got " . $jsonResponse["exitCode"] + ); } /** diff --git a/tests/acceptance/bootstrap/CollaborationContext.php b/tests/acceptance/bootstrap/CollaborationContext.php index ce080fe2294..250936fb0c5 100644 --- a/tests/acceptance/bootstrap/CollaborationContext.php +++ b/tests/acceptance/bootstrap/CollaborationContext.php @@ -86,7 +86,13 @@ public function getLastAppOpenData(): string { * * @throws GuzzleException */ - public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app, string $viewMode = null): void { + public function userChecksTheInformationOfFileOfSpaceUsingOffice( + string $user, + string $file, + string $space, + string $app, + string $viewMode = null + ): void { $fileId = $this->spacesContext->getFileId($user, $space, $file); $response = \json_decode( CollaborationHelper::sendPOSTRequestToAppOpen( @@ -127,7 +133,12 @@ public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, s * @return void * @throws GuzzleException */ - public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint(string $user, string $file, string $folder, string $space): void { + public function userCreatesFileInsideFolderInSpaceUsingWopiEndpoint( + string $user, + string $file, + string $folder, + string $space + ): void { $parentContainerId = $this->spacesContext->getResourceId($user, $space, $folder); $this->featureContext->setResponse( CollaborationHelper::createFile( @@ -193,7 +204,10 @@ public function createFile(string $file, string $password, string $folder = ""): * @return void * @throws GuzzleException */ - public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint(string $file, string $password): void { + public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPasswordUsingWopiEndpoint( + string $file, + string $password + ): void { $this->createFile($file, $password); } @@ -208,7 +222,11 @@ public function thePublicCreatesAFileInsideTheLastSharedPublicLinkFolderWithPass * @return void * @throws GuzzleException */ - public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint(string $file, string $folder, string $password): void { + public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceWithPasswordUsingWopiEndpoint( + string $file, + string $folder, + string $password + ): void { $this->createFile($file, $password, $folder); } @@ -225,7 +243,12 @@ public function thePublicCreatesAFileInsideFolderInTheLastSharedPublicLinkSpaceW * @throws GuzzleException * @throws JsonException */ - public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId(string $user, string $file, string $space, string $app): void { + public function userTriesToCheckTheInformationOfFileOfSpaceUsingOfficeWithInvalidFileId( + string $user, + string $file, + string $space, + string $app + ): void { $response = \json_decode( CollaborationHelper::sendPOSTRequestToAppOpen( $this->spacesContext->getFileId($user, $space, $file), @@ -335,9 +358,11 @@ public function userGetsTheInformationOfTheLastOpenedFileUsingWopiEndpoint(strin * @return void * @throws Exception */ - public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table):void { + public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, TableNode $table): void { $rows = $table->getRows(); - $responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['mime-types']; + $responseArray = $this->featureContext->getJsonDecodedResponse( + $this->featureContext->getResponse() + )['mime-types']; $mimeTypes = \array_column($responseArray, 'mime_type'); foreach ($rows as $row) { if ($shouldOrNot === "should not") { @@ -364,10 +389,17 @@ public function theFollowingMimeTypesShouldExistForUser(string $shouldOrNot, Tab * * @return void */ - public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice(string $app, TableNode $table): void { + public function theAppListResponseShouldContainTheFollowingTemplateInformationForOffice( + string $app, + TableNode $table + ): void { $responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()); - Assert::assertArrayHasKey("mime-types", $responseArray, "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true)); + Assert::assertArrayHasKey( + "mime-types", + $responseArray, + "Expected 'mime-types' in the response but not found.\n" . print_r($responseArray, true) + ); $mimeTypes = $responseArray['mime-types']; @@ -377,7 +409,12 @@ public function theAppListResponseShouldContainTheFollowingTemplateInformationFo } foreach ($table->getColumnsHash() as $row) { - Assert::assertArrayHasKey($row['mime-type'], $mimeTypeMap, "Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n" . print_r($mimeTypeMap, true)); + Assert::assertArrayHasKey( + $row['mime-type'], + $mimeTypeMap, + "Expected mime-type '{$row['mime-type']}' to exist in the response but it doesn't.\n" + . print_r($mimeTypeMap, true) + ); $mimeType = $mimeTypeMap[$row['mime-type']]; $found = false; @@ -387,7 +424,8 @@ public function theAppListResponseShouldContainTheFollowingTemplateInformationFo Assert::assertSame( $row['target-extension'], $provider['target_ext'], - "Expected 'target_ext' for $app to be '{$row['target-extension']}' but found '{$provider['target_ext']}'" + "Expected 'target_ext' for $app to be '{$row['target-extension']}'" + . " but found '{$provider['target_ext']}'" ); $found = true; break; @@ -396,8 +434,10 @@ public function theAppListResponseShouldContainTheFollowingTemplateInformationFo if (!$found) { Assert::fail( - "Expected response to contain app-provider '$app' with target-extension '{$row['target-extension']}' for mime-type '{$row['mime-type']}', but no matching provider was found.\n" . - "App Providers Found: " . print_r($mimeType['app_providers'], true) + "Expected response to contain app-provider '$app' with target-extension " + . "'{$row['target-extension']}' for mime-type '{$row['mime-type']}'," + . " but no matching provider was found.\n App Providers Found: " + . print_r($mimeType['app_providers'], true) ); } } @@ -412,7 +452,7 @@ public function theAppListResponseShouldContainTheFollowingTemplateInformationFo * @return string * @throws GuzzleException */ - public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file):string { + public function userHasCreatedAFileInSpaceUsingWopiEndpoint(string $user, string $file): string { $parentContainerId = $this->featureContext->getFileIdForPath($user, "/"); $response = CollaborationHelper::createFile( $this->featureContext->getBaseUrl(), diff --git a/tests/acceptance/bootstrap/FavoritesContext.php b/tests/acceptance/bootstrap/FavoritesContext.php index dd163cdd50e..c38f936e12f 100644 --- a/tests/acceptance/bootstrap/FavoritesContext.php +++ b/tests/acceptance/bootstrap/FavoritesContext.php @@ -43,7 +43,7 @@ class FavoritesContext implements Context { * * @return ResponseInterface */ - public function userFavoritesElement(string $user, string $path, string $spaceId = null):ResponseInterface { + public function userFavoritesElement(string $user, string $path, string $spaceId = null): ResponseInterface { return $this->changeFavStateOfAnElement( $user, $path, @@ -60,7 +60,7 @@ public function userFavoritesElement(string $user, string $path, string $spaceId * * @return void */ - public function userFavoritesElementUsingWebDavApi(string $user, string $path):void { + public function userFavoritesElementUsingWebDavApi(string $user, string $path): void { $this->featureContext->setResponse($this->userFavoritesElement($user, $path)); } @@ -72,7 +72,7 @@ public function userFavoritesElementUsingWebDavApi(string $user, string $path):v * * @return void */ - public function userHasFavoritedElementUsingWebDavApi(string $user, string $path):void { + public function userHasFavoritedElementUsingWebDavApi(string $user, string $path): void { $this->featureContext->theHTTPStatusCodeShouldBe(207, '', $this->userFavoritesElement($user, $path)); } @@ -82,7 +82,7 @@ public function userHasFavoritedElementUsingWebDavApi(string $user, string $path * * @return ResponseInterface */ - public function userUnfavoritesElement(string $user, string $path):ResponseInterface { + public function userUnfavoritesElement(string $user, string $path): ResponseInterface { return $this->changeFavStateOfAnElement( $user, $path, @@ -99,7 +99,7 @@ public function userUnfavoritesElement(string $user, string $path):ResponseInter * * @return void */ - public function userUnfavoritesElementUsingWebDavApi(string $user, string $path):void { + public function userUnfavoritesElementUsingWebDavApi(string $user, string $path): void { $this->featureContext->setResponse($this->userUnfavoritesElement($user, $path)); } @@ -116,7 +116,7 @@ public function checkFavoritedElements( string $user, string $shouldOrNot, TableNode $expectedElements - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $this->userListsFavorites($user); $this->featureContext->propfindResultShouldContainEntries( @@ -134,7 +134,7 @@ public function checkFavoritedElements( * * @return void */ - public function userListsFavorites(string $user, ?int $limit = null):void { + public function userListsFavorites(string $user, ?int $limit = null): void { $renamedUser = $this->featureContext->getActualUsername($user); $baseUrl = $this->featureContext->getBaseUrl(); $password = $this->featureContext->getPasswordForUser($user); @@ -176,7 +176,12 @@ public function userListsFavorites(string $user, ?int $limit = null):void { * * @return void */ - public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, int $expectedValue = 1, string $spaceId = null):void { + public function asUserFileOrFolderShouldBeFavorited( + string $user, + string $path, + int $expectedValue = 1, + string $spaceId = null + ): void { $property = "oc:favorite"; $this->webDavPropertiesContext->checkPropertyOfAFolder( $user, @@ -196,7 +201,7 @@ public function asUserFileOrFolderShouldBeFavorited(string $user, string $path, * * @return void */ - public function asUserFileShouldNotBeFavorited(string $user, string $path):void { + public function asUserFileShouldNotBeFavorited(string $user, string $path): void { $this->asUserFileOrFolderShouldBeFavorited($user, $path, 0); } @@ -215,7 +220,7 @@ public function changeFavStateOfAnElement( string $path, ?int $favOrUnfav, ?string $spaceId, - ):ResponseInterface { + ): ResponseInterface { $renamedUser = $this->featureContext->getActualUsername($user); return WebDavHelper::proppatch( $this->featureContext->getBaseUrl(), @@ -242,7 +247,7 @@ public function changeFavStateOfAnElement( * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context diff --git a/tests/acceptance/bootstrap/FeatureContext.php b/tests/acceptance/bootstrap/FeatureContext.php index b7144e1e97b..505080f5f36 100644 --- a/tests/acceptance/bootstrap/FeatureContext.php +++ b/tests/acceptance/bootstrap/FeatureContext.php @@ -1034,7 +1034,11 @@ public function usingServer(?string $server): string { private function checkInvalidValidator(JsonSchema $schemaObj): void { $validators = \array_keys((array)$schemaObj->jsonSerialize()); foreach ($validators as $validator) { - Assert::assertContains(\ltrim($validator, "$"), $this->jsonSchemaValidators, "Invalid schema validator: '$validator'"); + Assert::assertContains( + \ltrim($validator, "$"), + $this->jsonSchemaValidators, + "Invalid schema validator: '$validator'" + ); } } @@ -1091,7 +1095,9 @@ private function validateSchemaArray(JsonSchema $schemaObj): void { return; } - $hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const) || ($schemaObj->enum && $schemaObj->items) || ($schemaObj->const && $schemaObj->items); + $hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const) + || ($schemaObj->enum && $schemaObj->items) + || ($schemaObj->const && $schemaObj->items); Assert::assertFalse($hasTwoElementValidator, "'items', 'enum' and 'const' should not be used together"); if ($schemaObj->enum || $schemaObj->const) { // do not try to validate of enum or const is present @@ -1113,7 +1119,11 @@ private function validateSchemaArray(JsonSchema $schemaObj): void { Assert::assertNotNull($schemaObj->$validator, \sprintf($errMsg, $validator)); } - Assert::assertEquals($schemaObj->minItems, $schemaObj->maxItems, "'minItems' and 'maxItems' should be equal for strict assertion"); + Assert::assertEquals( + $schemaObj->minItems, + $schemaObj->maxItems, + "'minItems' and 'maxItems' should be equal for strict assertion" + ); // check optional validators foreach ($optionalValidators as $validator) { @@ -1127,18 +1137,34 @@ private function validateSchemaArray(JsonSchema $schemaObj): void { if ($schemaObj->maxItems > 1) { if (\is_array($value)) { foreach ($value as $element) { - Assert::assertNotNull($element->oneOf, "'oneOf' is required to assert more than one elements"); + Assert::assertNotNull( + $element->oneOf, + "'oneOf' is required to assert more than one elements" + ); } Assert::fail("'$validator' should be an object not an array"); } - Assert::assertFalse($value->allOf || $value->anyOf, "'allOf' and 'anyOf' are not allowed in array"); + Assert::assertFalse( + $value->allOf || $value->anyOf, + "'allOf' and 'anyOf' are not allowed in array" + ); if ($value->oneOf) { - Assert::assertNotNull($value->oneOf, "'oneOf' is required to assert more than one elements"); + Assert::assertNotNull( + $value->oneOf, + "'oneOf' is required to assert more than one elements" + ); Assert::assertTrue(\is_array($value->oneOf), "'oneOf' should be an array"); - Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf)); + Assert::assertEquals( + $schemaObj->maxItems, + \count($value->oneOf), + "Expected " . $schemaObj->maxItems . " 'oneOf' items but got " . \count($value->oneOf) + ); } } - Assert::assertTrue(\is_object($value), "'$validator' should be an object when expecting 1 element"); + Assert::assertTrue( + \is_object($value), + "'$validator' should be an object when expecting 1 element" + ); break; case "uniqueItems": if ($schemaObj->minItems > 1) { @@ -1340,7 +1366,12 @@ public function thePublicSendsHttpMethodToUrlWithPassword(string $method, string * @throws GuzzleException * @throws JsonException */ - public function userSendsHTTPMethodToUrlWithHeaders(string $user, string $verb, string $url, TableNode $headersTable): void { + public function userSendsHTTPMethodToUrlWithHeaders( + string $user, + string $verb, + string $url, + TableNode $headersTable + ): void { $this->verifyTableNodeColumns( $headersTable, ['header', 'value'] @@ -1385,7 +1416,12 @@ function ($subArray) { * * @return void */ - public function userSendsHttpMethodToUrlWithContent(string $user, string $method, string $davPath, string $content): void { + public function userSendsHttpMethodToUrlWithContent( + string $user, + string $method, + string $davPath, + string $content + ): void { $this->setResponse($this->sendingToWithDirectUrl($user, $method, $davPath, $content)); } @@ -1399,7 +1435,12 @@ public function userSendsHttpMethodToUrlWithContent(string $user, string $method * * @return void */ - public function userSendsHTTPMethodToUrlWithPassword(string $user, string $verb, string $url, string $password): void { + public function userSendsHTTPMethodToUrlWithPassword( + string $user, + string $verb, + string $url, + string $password + ): void { $this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url, null, $password)); } @@ -1414,7 +1455,14 @@ public function userSendsHTTPMethodToUrlWithPassword(string $user, string $verb, * @return ResponseInterface * @throws GuzzleException */ - public function sendingToWithDirectUrl(string $user, string $verb, string $url, ?string $body = null, ?string $password = null, ?array $headers = null): ResponseInterface { + public function sendingToWithDirectUrl( + string $user, + string $verb, + string $url, + ?string $body = null, + ?string $password = null, + ?array $headers = null + ): ResponseInterface { $url = \ltrim($url, '/'); if (WebdavHelper::isDAVRequest($url)) { $url = WebdavHelper::prefixRemotePhp($url); @@ -1498,12 +1546,17 @@ public function isAPublicLinkUrl(string $url): bool { * * @return void */ - public function theHTTPStatusCodeShouldBe($expectedStatusCode, ?string $message = "", ?ResponseInterface $response = null): void { + public function theHTTPStatusCodeShouldBe( + $expectedStatusCode, + ?string $message = "", + ?ResponseInterface $response = null + ): void { $response = $response ?? $this->response; $actualStatusCode = $response->getStatusCode(); if (\is_array($expectedStatusCode)) { if ($message === "") { - $message = "HTTP status code $actualStatusCode is not one of the expected values " . \implode(" or ", $expectedStatusCode); + $message = "HTTP status code $actualStatusCode is not one of the expected values " + . \implode(" or ", $expectedStatusCode); } Assert::assertContainsEquals( @@ -2745,7 +2798,11 @@ public function clearSpaceId(): void { * @return void * @throws Exception */ - public function verifyTableNodeColumns(?TableNode $table, ?array $requiredHeader = [], ?array $allowedHeader = []): void { + public function verifyTableNodeColumns( + ?TableNode $table, + ?array $requiredHeader = [], + ?array $allowedHeader = [] + ): void { if ($table === null || \count($table->getHash()) < 1) { throw new Exception("Table should have at least one row."); } @@ -2830,14 +2887,17 @@ public function verifyTableNodeColumnsCount(TableNode $table, int $count): void public function getBodyForOCSRequest(string $method, string $property): ?string { $body = null; if ($method === 'PROPFIND') { - $body = '<' . $property . '/>'; + $body = '<' + . $property . '/>'; } elseif ($method === 'LOCK') { - $body = " <" . $property . " />"; + $body = " <" + . $property . " />"; } elseif ($method === 'PROPPATCH') { if ($property === 'favorite') { $property = '1'; } - $body = '' . $property . ''; + $body = '' + . "" . $property . ''; } if ($property === '') { $body = ''; @@ -2877,7 +2937,7 @@ public function getUserIdByUserName(string $userName): string { * @return string * @throws Exception|GuzzleException */ - public function getGroupIdByGroupName(string $groupName):string { + public function getGroupIdByGroupName(string $groupName): string { $response = GraphHelper::getGroup( $this->getBaseUrl(), $this->getStepLineRef(), diff --git a/tests/acceptance/bootstrap/FilesVersionsContext.php b/tests/acceptance/bootstrap/FilesVersionsContext.php index abe78721597..a02fb4e8dd5 100644 --- a/tests/acceptance/bootstrap/FilesVersionsContext.php +++ b/tests/acceptance/bootstrap/FilesVersionsContext.php @@ -48,7 +48,7 @@ class FilesVersionsContext implements Context { * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -66,7 +66,7 @@ public function before(BeforeScenarioScope $scope):void { * @return void * @throws Exception */ - public function userTriesToGetFileVersions(string $user, string $file, string $fileOwner):void { + public function userTriesToGetFileVersions(string $user, string $file, string $fileOwner): void { $this->featureContext->setResponse($this->getFileVersions($user, $file, $fileOwner)); } @@ -79,7 +79,7 @@ public function userTriesToGetFileVersions(string $user, string $file, string $f * @return void * @throws Exception */ - public function userGetsFileVersions(string $user, string $file):void { + public function userGetsFileVersions(string $user, string $file): void { $this->featureContext->setResponse($this->getFileVersions($user, $file)); } @@ -92,7 +92,11 @@ public function userGetsFileVersions(string $user, string $file):void { * * @return void */ - public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId(string $file, string $password, string $fileId): void { + public function thePublicTriesToGetTheNumberOfVersionsOfFileWithPasswordUsingFileId( + string $file, + string $password, + string $fileId + ): void { $password = $this->featureContext->getActualPassword($password); $this->featureContext->setResponse( $this->featureContext->makeDavRequest( @@ -129,7 +133,11 @@ public function getFileVersions( $user = $this->featureContext->getActualUsername($user); $fileOwner = $fileOwner ? $this->featureContext->getActualUsername($fileOwner) : $user; $fileId = $this->featureContext->getFileIdForPath($fileOwner, $file, $spaceId); - Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $fileOwner not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . " fileid of file $file user $fileOwner not found (the file may not exist)" + ); return $this->featureContext->makeDavRequest( $user, "PROPFIND", @@ -150,7 +158,7 @@ public function getFileVersions( * * @return void */ - public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string $fileId):void { + public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string $fileId): void { $this->featureContext->setResponse( $this->featureContext->makeDavRequest( $user, @@ -173,7 +181,7 @@ public function userGetsTheNumberOfVersionsOfFileOfTheSpace(string $user, string * @return void * @throws Exception */ - public function userGetsVersionMetadataOfFile(string $user, string $file):void { + public function userGetsVersionMetadataOfFile(string $user, string $file): void { $response = $this->getFileVersionMetadata($user, $file); $this->featureContext->setResponse($response, $user); } @@ -184,10 +192,14 @@ public function userGetsVersionMetadataOfFile(string $user, string $file):void { * * @return ResponseInterface */ - public function getFileVersionMetadata(string $user, string $file) : ResponseInterface { + public function getFileVersionMetadata(string $user, string $file): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $file); - Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $file user $user not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . " fileid of file $file user $user not found (the file may not exist)" + ); $body = ' @@ -214,10 +226,14 @@ public function getFileVersionMetadata(string $user, string $file) : ResponseInt * @return ResponseInterface * @throws Exception */ - public function restoreVersionIndexOfFile(string $user, int $versionIndex, string $path):ResponseInterface { + public function restoreVersionIndexOfFile(string $user, int $versionIndex, string $path): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); - Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . " fileid of file $path user $user not found (the file may not exist)" + ); $response = $this->listVersionFolder($user, $fileId, 1); $responseXmlObject = HttpRequestHelper::getResponseXml( $response, @@ -249,7 +265,7 @@ public function restoreVersionIndexOfFile(string $user, int $versionIndex, strin * @return void * @throws Exception */ - public function userHasRestoredVersionIndexOfFile(string $user, int $versionIndex, string $path):void { + public function userHasRestoredVersionIndexOfFile(string $user, int $versionIndex, string $path): void { $response = $this->restoreVersionIndexOfFile($user, $versionIndex, $path); $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); } @@ -264,7 +280,7 @@ public function userHasRestoredVersionIndexOfFile(string $user, int $versionInde * @return void * @throws Exception */ - public function userRestoresVersionIndexOfFile(string $user, int $versionIndex, string $path):void { + public function userRestoresVersionIndexOfFile(string $user, int $versionIndex, string $path): void { $response = $this->restoreVersionIndexOfFile($user, $versionIndex, $path); $this->featureContext->setResponse($response, $user); } @@ -279,7 +295,7 @@ public function userRestoresVersionIndexOfFile(string $user, int $versionIndex, * @return void * @throws Exception */ - public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount):void { + public function assertFileVersionsCount(string $user, string $fileId, int $expectedCount): void { $response = $this->listVersionFolder($user, $fileId, 1); $responseXmlObject = HttpRequestHelper::getResponseXml( $response, @@ -310,10 +326,14 @@ public function theVersionFolderOfFileShouldContainElements( string $path, string $user, int $count - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); - Assert::assertNotNull($fileId, __METHOD__ . ". file '$path' for user '$user' not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . ". file '$path' for user '$user' not found (the file may not exist)" + ); $this->assertFileVersionsCount($user, $fileId, $count); } @@ -331,7 +351,7 @@ public function theVersionFolderOfFileIdShouldContainElements( string $fileId, string $user, int $count - ):void { + ): void { $this->assertFileVersionsCount($user, $fileId, $count); } @@ -351,10 +371,14 @@ public function theContentLengthOfFileForUserInVersionsFolderIs( int $index, string $user, int $length - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path); - Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . " fileid of file $path user $user not found (the file may not exist)" + ); $response = $this->listVersionFolder($user, $fileId, 1, ['d:getcontentlength']); $responseXmlObject = HttpRequestHelper::getResponseXml( $response, @@ -413,10 +437,19 @@ public function asUsersAuthorsOfVersionsOfFileShouldBe( * @return ResponseInterface * @throws Exception */ - public function downloadVersion(string $user, string $path, string $index, ?string $spaceId = null):ResponseInterface { + public function downloadVersion( + string $user, + string $path, + string $index, + ?string $spaceId = null + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $fileId = $this->featureContext->getFileIdForPath($user, $path, $spaceId); - Assert::assertNotNull($fileId, __METHOD__ . " fileid of file $path user $user not found (the file may not exist)"); + Assert::assertNotNull( + $fileId, + __METHOD__ + . " fileid of file $path user $user not found (the file may not exist)" + ); $index = (int)$index; $response = $this->listVersionFolder($user, $fileId, 1); if ($response->getStatusCode() === 403) { @@ -451,7 +484,7 @@ public function downloadVersion(string $user, string $path, string $index, ?stri * @return void * @throws Exception */ - public function userDownloadsVersion(string $user, string $path, string $index):void { + public function userDownloadsVersion(string $user, string $path, string $index): void { $this->featureContext->setResponse($this->downloadVersion($user, $path, $index), $user); } @@ -486,7 +519,7 @@ public function theContentOfVersionIndexOfFileForUserShouldBe( * * @return void */ - public function userGetMetaInfo(string $user, string $fileOrFileId, string $path):void { + public function userGetMetaInfo(string $user, string $fileOrFileId, string $path): void { $user = $this->featureContext->getActualUsername($user); $baseUrl = $this->featureContext->getBaseUrl(); $password = $this->featureContext->getPasswordForUser($user); @@ -538,7 +571,7 @@ public function listVersionFolder( string $fileId, int $folderDepth, ?array $properties = null - ):ResponseInterface { + ): ResponseInterface { if (!$properties) { $properties = [ 'd:getetag' diff --git a/tests/acceptance/bootstrap/GraphContext.php b/tests/acceptance/bootstrap/GraphContext.php index cb97be9162e..d5ca5d0dc56 100644 --- a/tests/acceptance/bootstrap/GraphContext.php +++ b/tests/acceptance/bootstrap/GraphContext.php @@ -81,7 +81,11 @@ public function theUserChangesTheEmailOfUserToUsingTheGraphApi(string $byUser, s * @throws GuzzleException * @throws Exception */ - public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $displayName): void { + public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi( + string $byUser, + string $user, + string $displayName + ): void { $response = $this->editUserUsingTheGraphApi($byUser, $user, null, null, null, $displayName); $this->featureContext->setResponse($response); } @@ -98,7 +102,11 @@ public function theUserChangesTheDisplayNameOfUserToUsingTheGraphApi(string $byU * @throws GuzzleException * @throws Exception */ - public function theUserChangesTheUserNameOfUserToUsingTheGraphApi(string $byUser, string $user, string $userName): void { + public function theUserChangesTheUserNameOfUserToUsingTheGraphApi( + string $byUser, + string $user, + string $userName + ): void { $response = $this->editUserUsingTheGraphApi($byUser, $user, $userName); $this->featureContext->setResponse($response); // need to add user to list to delete him after test @@ -189,7 +197,16 @@ public function theUserInformationShouldMatchTheJSON(string $user, PyStringNode * @return void * @throws GuzzleException */ - public function editUserUsingTheGraphApi(string $byUser, string $user, string $userName = null, string $password = null, string $email = null, string $displayName = null, bool $accountEnabled = true, string $method="PATCH"): ResponseInterface { + public function editUserUsingTheGraphApi( + string $byUser, + string $user, + string $userName = null, + string $password = null, + string $email = null, + string $displayName = null, + bool $accountEnabled = true, + string $method="PATCH" + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $user; return GraphHelper::editUser( @@ -528,8 +545,10 @@ public function theseUsersShouldBeInTheResponse(array $users): void { * @return array */ public function getAdminOrUserCredentials(?string $user): array { - $credentials["username"] = $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(); - $credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user) : $this->featureContext->getAdminPassword(); + $credentials["username"] = $user ? $this->featureContext->getActualUsername($user) + : $this->featureContext->getAdminUsername(); + $credentials["password"] = $user ? $this->featureContext->getPasswordForUser($user) + : $this->featureContext->getAdminPassword(); return $credentials; } /** @@ -574,7 +593,7 @@ public function getArrayOfGroupsResponded(ResponseInterface $response): array { * @throws GuzzleException */ public function adminHasRetrievedGroupListUsingTheGraphApi(): array { - return $this->getArrayOfGroupsResponded($this->listGroups()); + return $this->getArrayOfGroupsResponded($this->listGroups()); } /** @@ -605,7 +624,10 @@ public function listGroupMembers(string $group, ?string $user = null): ResponseI * @return ResponseInterface * @throws GuzzleException */ - public function listSingleOrAllGroupsAlongWithAllMemberInformation(string $user, ?string $group = null): ResponseInterface { + public function listSingleOrAllGroupsAlongWithAllMemberInformation( + string $user, + ?string $group = null + ): ResponseInterface { $credentials = $this->getAdminOrUserCredentials($user); return GraphHelper::getSingleOrAllGroupsAlongWithMembers( @@ -759,7 +781,10 @@ public function theAdministratorAddsTheFollowingUsersToTheFollowingGroupsUsingTh * * @return void */ - public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI(string $group, ?string $byUser = null): void { + public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI( + string $group, + ?string $byUser = null + ): void { $this->featureContext->setResponse($this->addUserToGroup($group, "nonexistent", $byUser)); } @@ -774,7 +799,10 @@ public function theAdministratorTriesToAddNonExistentUserToGroupUsingTheGraphAPI * * @throws GuzzleException | Exception */ - public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void { + public function theAdministratorTriesToAddUserToNonExistentGroupUsingTheGraphAPI( + string $user, + ?string $byUser = null + ): void { $this->featureContext->setResponse($this->addUserToGroup("nonexistent", $user, $byUser)); } @@ -799,7 +827,11 @@ public function theUserTriesToAddHimselfToGroupUsingTheGraphAPI(string $user, st * * @return void */ - public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI(string $byUser, string $user, string $group): void { + public function theUserTriesToAddAnotherUserToGroupUsingTheGraphAPI( + string $byUser, + string $user, + string $group + ): void { $this->featureContext->setResponse($this->addUserToGroup($group, $user, $byUser)); } @@ -1032,7 +1064,8 @@ public function theFollowingUsersShouldBeListedInFollowingGroups(TableNode $tabl Assert::assertTrue( $exists, __METHOD__ - . "\nExpected user '" . $userGroup['username'] . "' to be in group '" . $userGroup['groupname'] . "'. But not found." + . "\nExpected user '" . $userGroup['username'] . "' to be in group '" + . $userGroup['groupname'] . "'. But not found." ); } } @@ -1098,12 +1131,16 @@ public function userTriesToRenameNonExistentGroupToNewGroupName(string $user, st * * @return void */ - public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi(TableNode $table): void { + public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUsingTheGraphApi( + TableNode $table + ): void { $this->featureContext->verifyTableNodeColumns($table, ['username', 'groupname']); $usersGroups = $table->getColumnsHash(); foreach ($usersGroups as $userGroup) { - $this->featureContext->setResponse($this->removeUserFromGroup($userGroup['groupname'], $userGroup['username'])); + $this->featureContext->setResponse( + $this->removeUserFromGroup($userGroup['groupname'], $userGroup['username']) + ); $this->featureContext->pushToLastHttpStatusCodesArray(); } } @@ -1118,7 +1155,11 @@ public function theAdministratorRemovesTheFollowingUsersFromTheFollowingGroupsUs * @return void * @throws Exception | GuzzleException */ - public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string $user, string $group, ?string $byUser = null): void { + public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI( + string $user, + string $group, + ?string $byUser = null + ): void { $this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser)); } @@ -1132,7 +1173,10 @@ public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string * @return void * @throws GuzzleException */ - public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void { + public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI( + string $user, + ?string $byUser = null + ): void { $this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser)); } @@ -1145,7 +1189,7 @@ public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraph */ public function retrieveUserInformationUsingGraphApi( string $user - ):ResponseInterface { + ): ResponseInterface { $credentials = $this->getAdminOrUserCredentials($user); return GraphHelper::getOwnInformationAndGroupMemberships( $this->featureContext->getBaseUrl(), @@ -1165,7 +1209,7 @@ public function retrieveUserInformationUsingGraphApi( */ public function userRetrievesHisOrHerInformationOfUserUsingGraphApi( string $user - ):void { + ): void { $response = $this->retrieveUserInformationUsingGraphApi($user); $this->featureContext->setResponse($response); } @@ -1266,7 +1310,7 @@ public function userGetsAllUserUsingTheGraphApi(string $user) { public function retrieveUserInformationAlongWithDriveUsingGraphApi( string $byUser, ?string $user = null - ):ResponseInterface { + ): ResponseInterface { $user = $user ?? $byUser; $credentials = $this->getAdminOrUserCredentials($user); return GraphHelper::getUserWithDriveInformation( @@ -1289,7 +1333,7 @@ public function retrieveUserInformationAlongWithDriveUsingGraphApi( public function retrieveUserInformationAlongWithGroupUsingGraphApi( string $byUser, ?string $user = null - ):ResponseInterface { + ): ResponseInterface { $user = $user ?? $byUser; $credentials = $this->getAdminOrUserCredentials($user); return GraphHelper::getUserWithGroupInformation( @@ -1351,7 +1395,11 @@ public function userTriesToGetOwnDriveInformation(string $user) { * @throws GuzzleException * @throws Exception */ - public function addMultipleUsersToGroup(string $user, array $userIds, string $groupId): ResponseInterface { + public function addMultipleUsersToGroup( + string $user, + array $userIds, + string $groupId + ): ResponseInterface { $credentials = $this->getAdminOrUserCredentials($user); return GraphHelper::addUsersToGroup( @@ -1375,7 +1423,11 @@ public function addMultipleUsersToGroup(string $user, array $userIds, string $gr * @throws Exception * @throws GuzzleException */ - public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi(string $user, string $group, TableNode $table): void { + public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsingTheGraphApi( + string $user, + string $group, + TableNode $table + ): void { $userIds = []; $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); foreach ($table->getHash() as $row) { @@ -1397,7 +1449,11 @@ public function theAdministratorAddsTheFollowingUsersToAGroupInASingleRequestUsi * @throws Exception * @throws GuzzleException */ - public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi(string $user, string $group, TableNode $table): void { + public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsingTheGraphApi( + string $user, + string $group, + TableNode $table + ): void { $userIds = []; $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $credentials = $this->getAdminOrUserCredentials($user); @@ -1436,7 +1492,11 @@ public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidHostUsin * @throws Exception * @throws GuzzleException */ - public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(string $adminUser, string $user, string $group): void { + public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi( + string $adminUser, + string $user, + string $group + ): void { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $userId = $this->featureContext->getAttributeOfCreatedUser($user, "id"); $credentials = $this->getAdminOrUserCredentials($adminUser); @@ -1467,7 +1527,10 @@ public function userTriesToAddUserToGroupWithInvalidHostUsingTheGraphApi(string * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi(string $user, TableNode $table): void { + public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupAtOnceUsingTheGraphApi( + string $user, + TableNode $table + ): void { $userIds = []; $groupId = WebDavHelper::generateUUIDv4(); foreach ($table->getHash() as $row) { @@ -1489,7 +1552,11 @@ public function theAdministratorTriesToAddsTheFollowingUsersToANonExistingGroupA * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void { + public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAtOnceUsingTheGraphApi( + string $user, + string $group, + TableNode $table + ): void { $userIds = []; $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); foreach ($table->getHash() as $row) { @@ -1512,7 +1579,11 @@ public function theAdministratorTriesToAddTheFollowingNonExistingUsersToAGroupAt * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table): void { + public function theAdministratorTriesToAddTheFollowingUsersToAGroupAtOnceUsingTheGraphApi( + string $user, + string $group, + TableNode $table + ): void { $userIds = []; $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); foreach ($table->getHash() as $row) { @@ -1550,7 +1621,11 @@ public function userGetsAllApplicationsUsingTheGraphApi(string $user) { * @return void */ public function theResponseShouldContainTheFollowingApplicationInformation(TableNode $table): void { - Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]); + Assert::assertIsArray( + $responseArray = ( + $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()) + )['value'][0] + ); foreach ($table->getHash() as $row) { $key = $row["key"]; if ($key === 'id') { @@ -1572,7 +1647,11 @@ public function theResponseShouldContainTheFollowingApplicationInformation(Table * @return void */ public function theResponseShouldContainTheFollowingAppRolesInformation(TableNode $table): void { - Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]); + Assert::assertIsArray( + $responseArray = ( + $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()) + )['value'][0] + ); foreach ($table->getRows() as $row) { $foundRoleInResponse = false; foreach ($responseArray['appRoles'] as $role) { @@ -1640,7 +1719,11 @@ public function userGetsAllUsersOfTwoGroupsUsingTheGraphApi(string $user, string * @return void * @throws GuzzleException */ - public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi(string $user, string $firstGroup, string $secondGroup) { + public function userGetsAllUsersOfFirstGroupOderSecondGroupUsingTheGraphApi( + string $user, + string $firstGroup, + string $secondGroup + ) { $response = GraphHelper::getUsersFromOneOrOtherGroup( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -1708,7 +1791,11 @@ public function userGetsAllUsersWithRoleUsingTheGraphApi(string $user, string $r * @return void * @throws GuzzleException */ - public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi(string $user, string $role, string $group) { + public function userGetsAllUsersWithRoleAndMemberOfGroupUsingTheGraphApi( + string $user, + string $role, + string $group + ) { $response = GraphHelper::getUsersWithFilterRolesAssignmentAndMemberOf( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -1841,7 +1928,8 @@ public function theGraphApiResponseShouldHaveTheRole(string $role): void { $this->appEntity["appRoles"][$role], $response['appRoleId'], __METHOD__ - . "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role] . "' but got '" . $response['appRoleId'] . "'" + . "\nExpected rolId for role '$role'' to be '" . $this->appEntity["appRoles"][$role] + . "' but got '" . $response['appRoleId'] . "'" ); } @@ -1890,7 +1978,7 @@ public function userGetsDetailsOfTheGroupUsingTheGraphApi(string $user, string $ * * @return void */ - public function userSearchesForGroupUsingGraphApi(string $user, string $searchTerm):void { + public function userSearchesForGroupUsingGraphApi(string $user, string $searchTerm): void { $credentials = $this->getAdminOrUserCredentials($user); $this->featureContext->setResponse( GraphHelper::searchGroup( @@ -1953,7 +2041,11 @@ public function theJsonDataResponseShouldOrNotContainUserOrGroupAndMatch( * @throws GuzzleException * @throws Exception */ - public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table) { + public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi( + string $user, + string $group, + TableNode $table + ) { $userIds = []; $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); foreach ($table->getHash() as $row) { @@ -1975,13 +2067,18 @@ public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheG * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) { + public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi( + string $user, + string $groupToAdd, + string $group + ) { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id"); $credentials = $this->getAdminOrUserCredentials($user); $payload = [ - "members@odata.bind" => [GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)] + "members@odata.bind" => [ + GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)] ]; $this->featureContext->setResponse( @@ -2008,7 +2105,11 @@ public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(st * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(string $user, string $groupToAdd, string $group) { + public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi( + string $user, + string $groupToAdd, + string $group + ) { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id"); $credentials = $this->getAdminOrUserCredentials($user); @@ -2041,7 +2142,12 @@ public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingT * @throws Exception * @throws GuzzleException */ - public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(string $adminUser, string $user, string $group, string $invalidJSON): void { + public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi( + string $adminUser, + string $user, + string $group, + string $invalidJSON + ): void { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $credentials = $this->getAdminOrUserCredentials($adminUser); @@ -2078,7 +2184,12 @@ public function userTriesToAddUserToGroupWithInvalidJsonUsingTheGraphApi(string * @throws Exception * @throws GuzzleException */ - public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi(string $user, string $group, string $invalidJSON, TableNode $table): void { + public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsingTheGraphApi( + string $user, + string $group, + string $invalidJSON, + TableNode $table + ): void { $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $credentials = $this->getAdminOrUserCredentials($user); foreach ($table->getHash() as $row) { @@ -2116,7 +2227,11 @@ public function userTriesToAddTheFollowingUsersToAGroupAtOnceWithInvalidJsonUsin * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup(string $user, string $group, TableNode $table) { + public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacterToAGroup( + string $user, + string $group, + TableNode $table + ) { $userIds = []; $credentials = $this->getAdminOrUserCredentials($user); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); @@ -2146,7 +2261,11 @@ public function theAdministratorTriesToAddTheFollowingUserIdWithInvalidCharacter * @throws GuzzleException * @throws Exception */ - public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup(string $user, string $userId, string $group): void { + public function theAdministratorTriesToAddUserIdWithInvalidCharactersToAGroup( + string $user, + string $userId, + string $group + ): void { $credentials = $this->getAdminOrUserCredentials($user); $groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id"); $this->featureContext->setResponse( @@ -2183,7 +2302,8 @@ public function theUsersShouldBeListedOnceToAGroup(string $user, string $group): Assert::assertEquals( 1, $count, - "Expected user '" . $user . "' to be added once to group '" . $group . "' but the user is listed '" . $count . "' times" + "Expected user '" . $user . "' to be added once to group '" + . $group . "' but the user is listed '" . $count . "' times" ); } @@ -2248,7 +2368,11 @@ public function userGeneratesGDPRReportOfOwnDataToPath(string $user, string $pat * @throws Exception * */ - public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch(string $eventType, ?string $spaceType=null, PyStringNode $schemaString=null): void { + public function downloadedJsonContentShouldContainEventTypeInItemAndShouldMatch( + string $eventType, + ?string $spaceType=null, + PyStringNode $schemaString=null + ): void { $actualResponseToAssert = null; $events = $this->featureContext->getJsonDecodedResponseBodyContent()->events; foreach ($events as $event) { @@ -2307,7 +2431,11 @@ public function downloadedJsonContentShouldContainKeyUserAndMatch(PyStringNode $ * @return void * */ - public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(string $user, string $ofUser, string $path): void { + public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi( + string $user, + string $ofUser, + string $path + ): void { $credentials = $this->getAdminOrUserCredentials($user); $this->featureContext->setResponse( GraphHelper::generateGDPRReport( @@ -2328,7 +2456,8 @@ public function userTriesToExportGdprReportOfAnotherUserUsingGraphApi(string $us * @throws GuzzleException */ public function getAssignedRole(string $user): ResponseInterface { - $userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') ?: $this->featureContext->getUserIdByUserName($user); + $userId = $this->featureContext->getAttributeOfCreatedUser($user, 'id') + ?: $this->featureContext->getUserIdByUserName($user); return ( GraphHelper::getAssignedRole( $this->featureContext->getBAseUrl(), @@ -2359,7 +2488,9 @@ public function theUserUnassignsTheRoleOfUserUsingTheGraphApi(string $user, stri if (!$userId && $ofUser !== $this->featureContext->getAdminUsername()) { $appRoleAssignmentId = $this->getRoleIdByRoleName("User"); } else { - $appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse($this->getAssignedRole($ofUser))["value"][0]["id"]; + $appRoleAssignmentId = $this->featureContext->getJsonDecodedResponse( + $this->getAssignedRole($ofUser) + )["value"][0]["id"]; } $userId = $userId ?: $ofUser; @@ -2508,7 +2639,11 @@ public function userSwitchesTheSystemLanguageUsingGraphApi(string $user, string * @return void * @throws GuzzleException */ - public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString, string $retryOption): void { + public function userListsTheResourcesSharedWithThemUsingGraphApi( + string $user, + string $cacheStepString, + string $retryOption + ): void { if ($cacheStepString !== '') { // ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec // which means 60 sec is required to clean up all the user|group cache once they are deleted @@ -2537,7 +2672,9 @@ public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, s if ($retryEnabled) { foreach ($jsonBody->value as $share) { $autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']); - $tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); + $tryAgain = !$share->{'@client.synchronize'} + && $autoSync + && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); if ($tryAgain) { $retried += 1; @@ -2676,7 +2813,11 @@ public function theJsonDataResponseShouldNotContainUserEmail(): void { * @throws GuzzleException * @throws JsonException */ - public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes(string $byUser, string $password, string $user): void { + public function userUsingPasswordShouldBeAbleToCreateANewUserWithDefaultAttributes( + string $byUser, + string $password, + string $user + ): void { $response = GraphHelper::createUser( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -2749,7 +2890,7 @@ public function getListOfPermissionRoleDefinitionsUsingTheGraphAPI(string $user) * @throws GuzzleException * @throws Exception */ - public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $permissionRole):void { + public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $permissionRole): void { $credentials = $this->getAdminOrUserCredentials($user); $this->featureContext->setResponse( GraphHelper::getPermissionRoleDefinition( @@ -2772,7 +2913,11 @@ public function getPermissionRoleDefinitionUsingGraphAPI(string $user, string $p * @return void * @throws Exception */ - public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string $user, string $resource, string $spaceName): void { + public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI( + string $user, + string $resource, + string $spaceName + ): void { $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource); $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), @@ -2792,7 +2937,10 @@ public function userListsTheActivitiesForResourceOfSpaceUsingTheGraphAPI(string * * @return void */ - public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi(string $user, string $folder): void { + public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsingTheGraphApi( + string $user, + string $folder + ): void { $resourceId = GraphHelper::getShareMountId( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -2820,7 +2968,12 @@ public function userTriesToListTheActivitiesOfFolderWithShareMountIdPointIdUsing * * @return void */ - public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi(string $user, string $file, string $owner, string $spaceName): void { + public function userTriesToListActivitiesOfFileFromSpaceOwnedByUserUsingTheGraphApi( + string $user, + string $file, + string $owner, + string $spaceName + ): void { $resourceId = $this->featureContext->spacesContext->getResourceId($owner, $spaceName, $file); $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), @@ -2861,7 +3014,11 @@ public function userListsTheActivitiesOfSpaceUsingTheGraphApi(string $user, stri * * @return void */ - public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi(string $spaceName, string $user, string $password): void { + public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPasswordUsingGraphApi( + string $spaceName, + string $user, + string $password + ): void { $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -2882,7 +3039,12 @@ public function thePublicTriesToCheckTheActivitiesOfSpaceOwnedByUserWithPassword * * @return void */ - public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi(string $resource, string $space, string $owner, string $password): void { + public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUserWithPasswordUsingGraphApi( + string $resource, + string $space, + string $owner, + string $password + ): void { $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), $this->featureContext->getStepLineRef(), @@ -2904,7 +3066,13 @@ public function thePublicTriesToCheckTheActivitiesOfResourceFromSpaceOwnedByUser * * @return void */ - public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi(string $user, string $resource, string $spaceName, string $filterType, string $filterValue): void { + public function userListsTheActivitiesForFolderOfSpaceWithDepthOrLimitUsingTheGraphApi( + string $user, + string $resource, + string $spaceName, + string $filterType, + string $filterValue + ): void { $resourceId = $this->featureContext->spacesContext->getResourceId($user, $spaceName, $resource); $response = GraphHelper::getActivities( $this->featureContext->getBaseUrl(), @@ -2932,7 +3100,8 @@ public function theActivitiesShouldBeInTheFollowingOrder(TableNode $table): void foreach ($table->getHash() as $index => $expectedValue) { $actualActivity = $activities[$index]; $expectedActivity = $expectedValue['resource'] . ":" . $expectedValue['message']; - $actualActivity = $actualActivity->template->variables->resource->name . ":" . $actualActivity->template->message; + $actualActivity = $actualActivity->template->variables->resource->name + . ":" . $actualActivity->template->message; Assert::assertEquals($expectedActivity, $actualActivity, "Activity didn't match"); } } diff --git a/tests/acceptance/bootstrap/NotificationContext.php b/tests/acceptance/bootstrap/NotificationContext.php index 0aa84873087..e12e5a26292 100644 --- a/tests/acceptance/bootstrap/NotificationContext.php +++ b/tests/acceptance/bootstrap/NotificationContext.php @@ -36,14 +36,14 @@ class NotificationContext implements Context { /** * @return array[] */ - public function getNotificationIds():array { + public function getNotificationIds(): array { return $this->notificationIds; } /** * @return array[] */ - public function getLastNotificationId():array { + public function getLastNotificationId(): array { return \end($this->notificationIds); } @@ -95,7 +95,7 @@ public function getUserRecipient(): string { * @return void * @throws Exception */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -109,7 +109,7 @@ public function before(BeforeScenarioScope $scope):void { * * @return ResponseInterface */ - public function listAllNotifications(string $user):ResponseInterface { + public function listAllNotifications(string $user): ResponseInterface { $this->setUserRecipient($user); $language = SettingsHelper::getLanguageSettingValue( $this->featureContext->getBaseUrl(), @@ -138,7 +138,7 @@ public function listAllNotifications(string $user):ResponseInterface { * * @return void */ - public function userListAllNotifications(string $user):void { + public function userListAllNotifications(string $user): void { $response = $this->listAllNotifications($user); $this->featureContext->setResponse($response); $this->featureContext->pushToLastHttpStatusCodesArray(); @@ -151,7 +151,7 @@ public function userListAllNotifications(string $user):void { * @throws GuzzleException * @throws JsonException */ - public function deleteAllNotifications(string $user):ResponseInterface { + public function deleteAllNotifications(string $user): ResponseInterface { $response = $this->listAllNotifications($user); if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) { $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data; @@ -172,7 +172,7 @@ public function deleteAllNotifications(string $user):ResponseInterface { * @throws GuzzleException * @throws JsonException */ - public function userDeletesAllNotifications(string $user):void { + public function userDeletesAllNotifications(string $user): void { $response = $this->deleteAllNotifications($user); $this->featureContext->setResponse($response); } @@ -186,7 +186,7 @@ public function userDeletesAllNotifications(string $user):void { * @throws GuzzleException * @throws JsonException */ - public function userHasDeletedAllNotifications(string $user):void { + public function userHasDeletedAllNotifications(string $user): void { $response = $this->deleteAllNotifications($user); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -202,7 +202,7 @@ public function userHasDeletedAllNotifications(string $user):void { * @throws GuzzleException * @throws JsonException */ - public function userDeletesNotificationOfResourceAndSubject(string $user, string $resource, string $subject):void { + public function userDeletesNotificationOfResourceAndSubject(string $user, string $resource, string $subject): void { $response = $this->listAllNotifications($user); $this->filterNotificationsBySubjectAndResource($subject, $resource, $response); $this->featureContext->setResponse($this->userDeletesNotification($user)); @@ -217,7 +217,7 @@ public function userDeletesNotificationOfResourceAndSubject(string $user, string * @throws GuzzleException * @throws JsonException */ - public function userDeletesNotification(string $user):ResponseInterface { + public function userDeletesNotification(string $user): ResponseInterface { $this->setUserRecipient($user); $payload["ids"] = $this->getNotificationIds(); return OcsApiHelper::sendRequest( @@ -324,7 +324,10 @@ public function theJsonDataFromLastResponseShouldMatch( * * @return object */ - public function filterResponseAccordingToNotificationSubject(string $subject, ?ResponseInterface $response = null): object { + public function filterResponseAccordingToNotificationSubject( + string $subject, + ?ResponseInterface $response = null + ): object { $response = $response ?? $this->featureContext->getResponse(); if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) { $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data; @@ -351,7 +354,11 @@ public function filterResponseAccordingToNotificationSubject(string $subject, ?R * * @return array */ - public function filterNotificationsBySubjectAndResource(string $subject, string $resource, ?ResponseInterface $response = null): array { + public function filterNotificationsBySubjectAndResource( + string $subject, + string $resource, + ?ResponseInterface $response = null + ): array { $filteredNotifications = []; $response = $response ?? $this->featureContext->getResponse(); $responseObject = $this->featureContext->getJsonDecodedResponseBodyContent($response); @@ -362,7 +369,10 @@ public function filterNotificationsBySubjectAndResource(string $subject, string $notifications = $responseObject->ocs->data; foreach ($notifications as $notification) { - if (isset($notification->subject) && $notification->subject === $subject && isset($notification->messageRichParameters->resource->name) && $notification->messageRichParameters->resource->name === $resource) { + if (isset($notification->subject) && $notification->subject === $subject + && isset($notification->messageRichParameters->resource->name) + && $notification->messageRichParameters->resource->name === $resource + ) { $this->notificationIds[] = $notification->notification_id; $filteredNotifications[] = $notification; } @@ -380,7 +390,7 @@ public function filterNotificationsBySubjectAndResource(string $subject, string * @return void * @throws Exception */ - public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table):void { + public function userShouldGetANotificationWithMessage(string $user, string $subject, TableNode $table): void { $count = 0; // Sometimes the test might try to get the notifications before the server has created the notification. // To prevent the test from failing because of that, try to list the notifications again @@ -392,9 +402,15 @@ public function userShouldGetANotificationWithMessage(string $user, string $subj $response = $this->listAllNotifications($user); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); ++$count; - } while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message) && $count <= 5); + } while (!isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message) + && $count <= 5 + ); if (isset($this->filterResponseAccordingToNotificationSubject($subject, $response)->message)) { - $actualMessage = str_replace(["\r", "\n"], " ", $this->filterResponseAccordingToNotificationSubject($subject, $response)->message); + $actualMessage = str_replace( + ["\r", "\n"], + " ", + $this->filterResponseAccordingToNotificationSubject($subject, $response)->message + ); } else { throw new \Exception("Notification was not found even after retrying for 5 seconds."); } @@ -417,7 +433,12 @@ public function userShouldGetANotificationWithMessage(string $user, string $subj * @return void * @throws Exception */ - public function userShouldGetNotificationForResourceWithMessage(string $user, string $resource, string $subject, TableNode $table):void { + public function userShouldGetNotificationForResourceWithMessage( + string $user, + string $resource, + string $subject, + TableNode $table + ): void { $response = $this->listAllNotifications($user); $notification = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response); @@ -432,9 +453,15 @@ public function userShouldGetNotificationForResourceWithMessage(string $user, st $response = $this->userDeletesNotification($user); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); } elseif (\count($notification) === 0) { - throw new \Exception("Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true)); + throw new \Exception( + "Response doesn't contain any notification with resource '$resource' and subject '$subject'.\n" + . print_r($notification, true) + ); } else { - throw new \Exception("Response contains more than one notification with resource '$resource' and subject '$subject'.\n" . print_r($notification, true)); + throw new \Exception( + "Response contains more than one notification with resource '$resource' and subject '$subject'.\n" + . print_r($notification, true) + ); } } @@ -447,10 +474,19 @@ public function userShouldGetNotificationForResourceWithMessage(string $user, st * * @return void */ - public function userShouldNotHaveANotificationRelatedToResourceWithSubject(string $user, string $resource, string $subject):void { + public function userShouldNotHaveANotificationRelatedToResourceWithSubject( + string $user, + string $resource, + string $subject + ): void { $response = $this->listAllNotifications($user); $filteredResponse = $this->filterNotificationsBySubjectAndResource($subject, $resource, $response); - Assert::assertCount(0, $filteredResponse, "Response should not contain notification related to resource '$resource' with subject '$subject' but found" . print_r($filteredResponse, true)); + Assert::assertCount( + 0, + $filteredResponse, + "Response should not contain notification related to resource '$resource' with subject '$subject' but found" + . print_r($filteredResponse, true) + ); } /** @@ -464,7 +500,12 @@ public function userShouldNotHaveANotificationRelatedToResourceWithSubject(strin * @return void * @throws Exception */ - public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace(string $user, string $sender, string $spaceName, PyStringNode $content):void { + public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfProjectSpace( + string $user, + string $sender, + string $spaceName, + PyStringNode $content + ): void { $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw()); $this->featureContext->setResponse( GraphHelper::getMySpaces( @@ -501,7 +542,11 @@ public function userShouldHaveReceivedTheFollowingEmailFromUserAboutTheShareOfPr * @return void * @throws Exception */ - public function userShouldHaveReceivedTheFollowingEmailFromUser(string $user, string $sender, PyStringNode $content):void { + public function userShouldHaveReceivedTheFollowingEmailFromUser( + string $user, + string $sender, + PyStringNode $content + ): void { $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw()); $expectedEmailBodyContent = $this->featureContext->substituteInLineCodes( $rawExpectedEmailBodyContent, @@ -520,7 +565,11 @@ public function userShouldHaveReceivedTheFollowingEmailFromUser(string $user, st * @return void * @throws Exception */ - public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(string $user, string $sender, PyStringNode $content):void { + public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces( + string $user, + string $sender, + PyStringNode $content + ): void { $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw()); $expectedEmailBodyContent = $this->featureContext->substituteInLineCodes( $rawExpectedEmailBodyContent, @@ -537,7 +586,11 @@ public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespac * @return void * @throws GuzzleException */ - public function assertEmailContains(string $user, string $expectedEmailBodyContent, $ignoreWhiteSpace = false):void { + public function assertEmailContains( + string $user, + string $expectedEmailBodyContent, + $ignoreWhiteSpace = false + ): void { $address = $this->featureContext->getEmailAddressForUser($user); $this->featureContext->pushEmailRecipientAsMailBox($address); $actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef()); @@ -548,7 +601,8 @@ public function assertEmailContains(string $user, string $expectedEmailBodyConte Assert::assertStringContainsString( $expectedEmailBodyContent, $actualEmailBodyContent, - "The email address '$address' should have received an email with the body containing $expectedEmailBodyContent + "The email address '$address' should have received an" + . "email with the body containing $expectedEmailBodyContent but the received email is $actualEmailBodyContent" ); } @@ -560,7 +614,7 @@ public function assertEmailContains(string $user, string $expectedEmailBodyConte * * @return void */ - public function clearInbucketMessages():void { + public function clearInbucketMessages(): void { try { if (!empty($this->featureContext->emailRecipients)) { foreach ($this->featureContext->emailRecipients as $emailRecipient) { @@ -594,9 +648,10 @@ public function userCreatesDeprovisioningNotification( ?string $user = null, ?string $deprovision_date = "2043-07-04T11:23:12Z", ?string $deprovision_date_format= "2006-01-02T15:04:05Z07:00" - ):ResponseInterface { + ): ResponseInterface { $payload["type"] = "deprovision"; - $payload["data"] = ["deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format]; + $payload["data"] = [ + "deprovision_date" => $deprovision_date, "deprovision_date_format" => $deprovision_date_format]; return OcsApiHelper::sendRequest( $this->featureContext->getBaseUrl(), $user ? $this->featureContext->getActualUsername($user) : $this->featureContext->getAdminUsername(), @@ -636,7 +691,10 @@ public function theAdministratorCreatesADeprovisioningNotification(?string $user * @throws GuzzleException * @throws JsonException */ - public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat($deprovision_date, $deprovision_date_format) { + public function theAdministratorCreatesADeprovisioningNotificationUsingDateFormat( + $deprovision_date, + $deprovision_date_format + ) { $response = $this->userCreatesDeprovisioningNotification(null, $deprovision_date, $deprovision_date_format); $this->featureContext->setResponse($response); $this->featureContext->pushToLastHttpStatusCodesArray(); @@ -647,7 +705,7 @@ public function theAdministratorCreatesADeprovisioningNotificationUsingDateForma * * @return void */ - public function userHasCreatedDeprovisioningNotification():void { + public function userHasCreatedDeprovisioningNotification(): void { $response = $this->userCreatesDeprovisioningNotification(); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -660,7 +718,7 @@ public function userHasCreatedDeprovisioningNotification():void { * * @return void */ - public function userDeletesDeprovisioningNotification(?string $user = null):void { + public function userDeletesDeprovisioningNotification(?string $user = null): void { $payload["ids"] = ["deprovision"]; $response = OcsApiHelper::sendRequest( diff --git a/tests/acceptance/bootstrap/OCSContext.php b/tests/acceptance/bootstrap/OCSContext.php index 2a0ee2f0b0a..73b58ffd9ff 100644 --- a/tests/acceptance/bootstrap/OCSContext.php +++ b/tests/acceptance/bootstrap/OCSContext.php @@ -47,7 +47,7 @@ class OCSContext implements Context { * * @return void */ - public function theUserSendsToOcsApiEndpoint(string $verb, string $url):void { + public function theUserSendsToOcsApiEndpoint(string $verb, string $url): void { $response = $this->theUserSendsToOcsApiEndpointWithBody($verb, $url); $this->featureContext->setResponse($response); } @@ -63,7 +63,7 @@ public function theUserSendsToOcsApiEndpoint(string $verb, string $url):void { * * @return void */ - public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null):void { + public function userSendsToOcsApiEndpoint(string $user, string $verb, string $url, ?string $password = null): void { $response = $this->sendRequestToOcsEndpoint( $user, $verb, @@ -91,7 +91,7 @@ public function sendRequestToOcsEndpoint( ?TableNode $body = null, ?string $password = null, ?array $headers = null - ):ResponseInterface { + ): ResponseInterface { /** * array of the data to be sent in the body. * contains $body data converted to an array @@ -134,7 +134,7 @@ public function adminSendsHttpMethodToOcsApiEndpointWithBody( string $verb, string $url, ?TableNode $body - ):ResponseInterface { + ): ResponseInterface { $admin = $this->featureContext->getAdminUsername(); return $this->sendRequestToOcsEndpoint( $admin, @@ -151,7 +151,11 @@ public function adminSendsHttpMethodToOcsApiEndpointWithBody( * * @return ResponseInterface */ - public function theUserSendsToOcsApiEndpointWithBody(string $verb, string $url, ?TableNode $body = null):ResponseInterface { + public function theUserSendsToOcsApiEndpointWithBody( + string $verb, + string $url, + ?TableNode $body = null + ): ResponseInterface { return $this->sendRequestToOcsEndpoint( $this->featureContext->getCurrentUser(), $verb, @@ -177,7 +181,7 @@ public function userSendHTTPMethodToOcsApiEndpointWithBody( string $url, ?TableNode $body = null, ?string $password = null - ):void { + ): void { $response = $this->sendRequestToOcsEndpoint( $user, $verb, @@ -202,7 +206,7 @@ public function theAdministratorSendsHttpMethodToOcsApiEndpoint( string $verb, string $url, ?string $password = null - ):void { + ): void { $this->featureContext->setResponse( $this->sendRequestToOcsEndpoint( $this->featureContext->getAdminUsername(), @@ -230,7 +234,7 @@ public function userSendsToOcsApiEndpointWithHeaders( string $verb, string $url, TableNode $headersTable - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $password = $this->featureContext->getPasswordForUser($user); $this->featureContext->setResponse( @@ -259,7 +263,7 @@ public function administratorSendsToOcsApiEndpointWithHeaders( string $verb, string $url, TableNode $headersTable - ):void { + ): void { $user = $this->featureContext->getAdminUsername(); $password = $this->featureContext->getPasswordForUser($user); $this->featureContext->setResponse( @@ -290,7 +294,7 @@ public function administratorSendsToOcsApiEndpointWithHeadersAndPassword( string $url, string $password, TableNode $headersTable - ):void { + ): void { $this->featureContext->setResponse( $this->sendRequestToOcsEndpoint( $this->featureContext->getAdminUsername(), @@ -316,7 +320,7 @@ public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody( string $verb, string $url, ?TableNode $body - ):void { + ): void { $response = $this->adminSendsHttpMethodToOcsApiEndpointWithBody( $verb, $url, @@ -334,7 +338,7 @@ public function theAdministratorSendsHttpMethodToOcsApiEndpointWithBody( * * @return void */ - public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body):void { + public function theUserSendsHTTPMethodToOcsApiEndpointWithBody(string $verb, string $url, TableNode $body): void { $response = $this->theUserSendsToOcsApiEndpointWithBody( $verb, $url, @@ -358,7 +362,7 @@ public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword( string $url, string $password, TableNode $body - ):void { + ): void { $admin = $this->featureContext->getAdminUsername(); $response = $this->sendRequestToOcsEndpoint( $admin, @@ -387,7 +391,7 @@ public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword( string $url, string $password, TableNode $body - ):void { + ): void { $response = $this->sendRequestToOcsEndpoint( $user, $verb, @@ -408,7 +412,11 @@ public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword( * @return void * @throws Exception */ - public function theOCSStatusCodeShouldBe(string $statusCode, string $message = "", ?ResponseInterface $response = null):void { + public function theOCSStatusCodeShouldBe( + string $statusCode, + string $message = "", + ?ResponseInterface $response = null + ): void { $statusCodes = explode(",", $statusCode); $response = $response ?? $this->featureContext->getResponse(); $responseStatusCode = $this->getOCSResponseStatusCode( @@ -416,7 +424,8 @@ public function theOCSStatusCodeShouldBe(string $statusCode, string $message = " ); if (\is_array($statusCodes)) { if ($message === "") { - $message = "OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode; + $message = "OCS status code is not any of the expected values " + . \implode(",", $statusCodes) . " got " . $responseStatusCode; } Assert::assertContainsEquals( $responseStatusCode, @@ -446,7 +455,7 @@ public function theOCSStatusCodeShouldBe(string $statusCode, string $message = " * @return void * @throws Exception */ - public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCode2):void { + public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCode2): void { $statusCodes = [$statusCode1,$statusCode1]; $response = $this->featureContext->getResponse(); $responseStatusCode = $this->getOCSResponseStatusCode( @@ -455,7 +464,8 @@ public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCo Assert::assertContainsEquals( $responseStatusCode, $statusCodes, - "OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode + "OCS status code is not any of the expected values " + . \implode(",", $statusCodes) . " got " . $responseStatusCode ); $this->featureContext->emptyLastOCSStatusCodesArray(); } @@ -471,7 +481,7 @@ public function theOcsStatusCodeShouldBeOr(string $statusCode1, string $statusCo * * @return void */ - public function theOCSStatusMessageShouldBe(string $statusMessage, ?string $language = null):void { + public function theOCSStatusMessageShouldBe(string $statusMessage, ?string $language = null): void { $language = TranslationHelper::getLanguage($language); $statusMessage = $this->getActualStatusMessage($statusMessage, $language); @@ -496,7 +506,7 @@ public function theOCSStatusMessageShouldBe(string $statusMessage, ?string $lang * * @return void */ - public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage):void { + public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statusMessage): void { $user = \strtolower($this->featureContext->getActualUsername($user)); $statusMessage = $this->featureContext->substituteInLineCodes( $statusMessage, @@ -533,7 +543,7 @@ public function theOCSStatusMessageAboutUserShouldBe(string $user, string $statu */ public function theOCSStatusMessageShouldBePyString( PyStringNode $statusMessage - ):void { + ): void { Assert::assertEquals( $statusMessage->getRaw(), $this->getOCSResponseStatusMessage( @@ -554,7 +564,7 @@ public function theOCSStatusMessageShouldBePyString( * @return string * @throws Exception */ - public function getOCSResponseStatusCode(ResponseInterface $response):string { + public function getOCSResponseStatusCode(ResponseInterface $response): string { try { $jsonResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response); } catch (JsonException $e) { @@ -596,7 +606,7 @@ public function getOCSResponseData(ResponseInterface $response): SimpleXMLElemen * * @return string */ - public function getOCSResponseStatusMessage(ResponseInterface $response):string { + public function getOCSResponseStatusMessage(ResponseInterface $response): string { return (string) HttpRequestHelper::getResponseXml($response, __METHOD__)->meta[0]->message; } @@ -608,7 +618,7 @@ public function getOCSResponseStatusMessage(ResponseInterface $response):string * * @return string */ - public function getActualStatusMessage(string $statusMessage, ?string $language = null):string { + public function getActualStatusMessage(string $statusMessage, ?string $language = null): string { if ($language !== null) { $multiLingualMessage = \json_decode( \file_get_contents(__DIR__ . "/../fixtures/multiLanguageErrors.json"), @@ -632,7 +642,10 @@ public function getActualStatusMessage(string $statusMessage, ?string $language * @return void * @throws Exception */ - public function assertOCSResponseIndicatesSuccess(?string $message = "", ?ResponseInterface $response = null):void { + public function assertOCSResponseIndicatesSuccess( + ?string $message = "", + ?ResponseInterface $response = null + ): void { $response = $response ?? $this->featureContext->getResponse(); $this->featureContext->theHTTPStatusCodeShouldBe('200', $message, $response); if ($this->featureContext->getOcsApiVersion() === 1) { @@ -652,7 +665,7 @@ public function assertOCSResponseIndicatesSuccess(?string $message = "", ?Respon * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context diff --git a/tests/acceptance/bootstrap/OcmContext.php b/tests/acceptance/bootstrap/OcmContext.php index 90181a35987..89e95a70ff2 100644 --- a/tests/acceptance/bootstrap/OcmContext.php +++ b/tests/acceptance/bootstrap/OcmContext.php @@ -56,7 +56,7 @@ public function before(BeforeScenarioScope $scope): void { * @return string * @throws Exception */ - public function getLastFederatedInvitationToken():string { + public function getLastFederatedInvitationToken(): string { if (empty($this->invitationToken)) { throw new Exception(__METHOD__ . " token not found"); } @@ -286,7 +286,11 @@ public function userDeletesFederatedConnectionWithUserUsingTheGraphApi(string $u */ public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void { $response = $this->deleteConnection($user, $ocmUser); - $this->featureContext->theHTTPStatusCodeShouldBe(200, "failed while deleting connection with user $ocmUser", $response); + $this->featureContext->theHTTPStatusCodeShouldBe( + 200, + "failed while deleting connection with user $ocmUser", + $response + ); } /** diff --git a/tests/acceptance/bootstrap/Provisioning.php b/tests/acceptance/bootstrap/Provisioning.php index 487b6e2aa36..ca96d55a06d 100644 --- a/tests/acceptance/bootstrap/Provisioning.php +++ b/tests/acceptance/bootstrap/Provisioning.php @@ -59,7 +59,7 @@ trait Provisioning { * * @return boolean */ - public function isLocalAdminGroup(string $groupname):bool { + public function isLocalAdminGroup(string $groupname): bool { return ($groupname === "admin"); } @@ -72,28 +72,28 @@ public function isLocalAdminGroup(string $groupname):bool { * * @return string */ - public function normalizeUsername(?string $username):string { + public function normalizeUsername(?string $username): string { return \strtolower((string)$username); } /** * @return array */ - public function getCreatedUsers():array { + public function getCreatedUsers(): array { return $this->createdUsers; } /** * @return array */ - public function getAllCreatedUsers():array { + public function getAllCreatedUsers(): array { return array_merge($this->createdUsers, $this->createdRemoteUsers); } /** * @return array */ - public function getCreatedGroups():array { + public function getCreatedGroups(): array { return $this->createdGroups; } @@ -105,7 +105,7 @@ public function getCreatedGroups():array { * * @return string */ - public function getUserDisplayName(string $username):string { + public function getUserDisplayName(string $username): string { $normalizedUsername = $this->normalizeUsername($username); $users = $this->getAllCreatedUsers(); if (isset($users[$normalizedUsername]['displayname'])) { @@ -169,7 +169,7 @@ public function getAttributeOfCreatedGroup(string $group, string $attribute) { * @return string password * @throws Exception */ - public function getUserPassword(string $username):string { + public function getUserPassword(string $username): string { $normalizedUsername = $this->normalizeUsername($username); if ($normalizedUsername === $this->getAdminUsername()) { $password = $this->getAdminPassword(); @@ -197,7 +197,7 @@ public function getUserPassword(string $username):string { */ public function userHasBeenCreatedWithDefaultAttributes( string $user - ):void { + ): void { $this->userHasBeenCreated(["userName" => $user]); } @@ -211,7 +211,7 @@ public function userHasBeenCreatedWithDefaultAttributes( */ public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized( TableNode $table - ):void { + ): void { $this->usersHaveBeenCreated($table, true, false); } @@ -225,7 +225,7 @@ public function userHasBeenCreatedWithDefaultAttributesAndNotInitialized( * @return void * @throws Exception|GuzzleException */ - public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table):void { + public function theseUsersHaveBeenCreatedWithDefaultAttributesAndWithoutSkeletonFiles(TableNode $table): void { $this->usersHaveBeenCreated($table); } @@ -253,7 +253,7 @@ public function theAdministratorHasCreatedANewUserWithFollowingSettings(string $ * @return boolean * @throws Exception */ - public function theGroupShouldBeAbleToBeDeleted(string $groupname):bool { + public function theGroupShouldBeAbleToBeDeleted(string $groupname): bool { if (\array_key_exists($groupname, $this->createdGroups)) { return $this->createdGroups[$groupname]['possibleToDelete'] ?? true; } @@ -274,7 +274,7 @@ public function theGroupShouldBeAbleToBeDeleted(string $groupname):bool { * * @return void */ - public function importLdifFile(string $path):void { + public function importLdifFile(string $path): void { $ldifData = \file_get_contents($path); $this->importLdifData($ldifData); } @@ -286,7 +286,7 @@ public function importLdifFile(string $path):void { * * @return void */ - public function importLdifData(string $ldifData):void { + public function importLdifData(string $ldifData): void { $items = Laminas\Ldap\Ldif\Encoder::decode($ldifData); if (isset($items['dn'])) { //only one item in the ldif data @@ -314,7 +314,7 @@ public function importLdifData(string $ldifData):void { * @throws Exception * @throws \LdapException */ - public function connectToLdap(array $suiteParameters):void { + public function connectToLdap(array $suiteParameters): void { $this->ldapBaseDN = OcisHelper::getBaseDN(); $this->ldapUsersOU = OcisHelper::getUsersOU(); $this->ldapGroupsOU = OcisHelper::getGroupsOU(); @@ -365,7 +365,7 @@ public function connectToLdap(array $suiteParameters):void { * @return array * @throws JsonException */ - public function buildUsersAttributesArray(bool $setDefaultAttributes, array $table):array { + public function buildUsersAttributesArray(bool $setDefaultAttributes, array $table): array { $usersAttributes = []; foreach ($table as $row) { $userAttribute['userid'] = $this->getActualUsername($row['username']); @@ -412,7 +412,7 @@ public function buildUsersAttributesArray(bool $setDefaultAttributes, array $tab * @return void * @throws Exception */ - public function createLdapUser(array $setting):void { + public function createLdapUser(array $setting): void { $ou = $this->ldapUsersOU ; // Some special characters need to be escaped in LDAP DN and attributes // The special characters allowed in a username (UID) are +_.@- @@ -455,7 +455,11 @@ public function createLdapUser(array $setting):void { } catch (LdapException $e) { if (\str_contains($e->getMessage(), "Already exists")) { $this->ldap->delete( - "uid=" . ldap_escape($entry['uid'], "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, + "uid=" . ldap_escape( + $entry['uid'], + "", + LDAP_ESCAPE_DN + ) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, ); OcisHelper::deleteRevaUserData([$entry['uid']]); $this->ldap->add($newDN, $entry); @@ -472,7 +476,7 @@ public function createLdapUser(array $setting):void { * @throws Exception * @throws LdapException */ - public function createLdapGroup(string $group):void { + public function createLdapGroup(string $group): void { $baseDN = $this->getLdapBaseDN(); $newDN = 'cn=' . $group . ',ou=' . $this->ldapGroupsOU . ',' . $baseDN; $entry = []; @@ -496,7 +500,8 @@ public function createLdapGroup(string $group):void { } catch (LdapException $e) { if (\str_contains($e->getMessage(), "Already exists")) { $this->ldap->delete( - "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, + "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) + . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, ); $this->ldap->add($newDN, $entry); } @@ -510,7 +515,7 @@ public function createLdapGroup(string $group):void { * @return void * @throws Exception */ - public function deleteLdapUsersAndGroups():void { + public function deleteLdapUsersAndGroups(): void { foreach ($this->ldapCreatedUsers as $user) { $this->ldap->delete( "uid=" . ldap_escape($user, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapUsersOU . "," . $this->ldapBaseDN, @@ -519,7 +524,8 @@ public function deleteLdapUsersAndGroups():void { } foreach ($this->ldapCreatedGroups as $group) { $this->ldap->delete( - "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, + "cn=" . ldap_escape($group, "", LDAP_ESCAPE_DN) + . ",ou=" . $this->ldapGroupsOU . "," . $this->ldapBaseDN, ); $this->rememberThatGroupIsNotExpectedToExist($group); } @@ -667,7 +673,7 @@ public function usersHaveBeenCreated( * * @return void */ - public function resetUserPasswordAsAdminUsingTheProvisioningApi(string $username, ?string $password):void { + public function resetUserPasswordAsAdminUsingTheProvisioningApi(string $username, ?string $password): void { $this->userResetUserPasswordUsingProvisioningApi( $this->getAdminUsername(), $username, @@ -682,7 +688,11 @@ public function resetUserPasswordAsAdminUsingTheProvisioningApi(string $username * * @return void */ - public function userResetUserPasswordUsingProvisioningApi(?string $user, ?string $username, ?string $password):void { + public function userResetUserPasswordUsingProvisioningApi( + ?string $user, + ?string $username, + ?string $password + ): void { $targetUsername = $this->getActualUsername($username); $password = $this->getActualPassword($password); $this->userTriesToResetUserPasswordUsingTheProvisioningApi( @@ -700,7 +710,11 @@ public function userResetUserPasswordUsingProvisioningApi(?string $user, ?string * * @return void */ - public function userTriesToResetUserPasswordUsingTheProvisioningApi(?string $user, ?string $username, ?string $password):void { + public function userTriesToResetUserPasswordUsingTheProvisioningApi( + ?string $user, + ?string $username, + ?string $password + ): void { $password = $this->getActualPassword($password); $bodyTable = new TableNode([['key', 'password'], ['value', $password]]); $this->ocsContext->sendRequestToOcsEndpoint( @@ -719,7 +733,7 @@ public function userTriesToResetUserPasswordUsingTheProvisioningApi(?string $use * @return void * @throws Exception */ - public function theAdminDeletesUserUsingTheProvisioningApi(string $user):void { + public function theAdminDeletesUserUsingTheProvisioningApi(string $user): void { $user = $this->getActualUsername($user); $this->setResponse($this->deleteUser($user)); $this->pushToLastHttpStatusCodesArray(); @@ -733,7 +747,7 @@ public function theAdminDeletesUserUsingTheProvisioningApi(string $user):void { * @return void * @throws JsonException */ - public function userShouldExist(string $user):void { + public function userShouldExist(string $user): void { Assert::assertTrue( $this->userExists($user), "User '$user' should exist but does not exist" @@ -748,7 +762,7 @@ public function userShouldExist(string $user):void { * @return void * @throws JsonException */ - public function userShouldNotExist(string $user):void { + public function userShouldNotExist(string $user): void { $user = $this->getActualUsername($user); Assert::assertFalse( $this->userExists($user), @@ -766,7 +780,7 @@ public function userShouldNotExist(string $user):void { * @throws Exception * @throws GuzzleException */ - public function groupShouldExist(string $group):void { + public function groupShouldExist(string $group): void { Assert::assertTrue( $this->groupExists($group), "Group '$group' should exist but does not exist" @@ -782,7 +796,7 @@ public function groupShouldExist(string $group):void { * @throws Exception * @throws GuzzleException */ - public function groupShouldNotExist(string $group):void { + public function groupShouldNotExist(string $group): void { Assert::assertFalse( $this->groupExists($group), "Group '$group' should not exist but does exist" @@ -799,7 +813,7 @@ public function groupShouldNotExist(string $group):void { * @return void * @throws Exception */ - public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table):void { + public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table): void { $should = ($shouldOrNot !== "not"); $this->verifyTableNodeColumns($table, ['groupname']); if ($this->isTestingWithLdap()) { @@ -826,7 +840,7 @@ public function theseGroupsShouldNotExist(string $shouldOrNot, TableNode $table) * @return void * @throws Exception */ - public function userHasBeenDeleted(string $user):void { + public function userHasBeenDeleted(string $user): void { $user = $this->getActualUsername($user); if ($this->userExists($user)) { if ($this->isTestingWithLdap() && \in_array($user, $this->ldapCreatedUsers)) { @@ -853,7 +867,7 @@ public function userHasBeenDeleted(string $user):void { * * @return void */ - public function theseUsersHaveBeenInitialized(TableNode $table):void { + public function theseUsersHaveBeenInitialized(TableNode $table): void { foreach ($table as $row) { if (!isset($row ['password'])) { $password = $this->getPasswordForUser($row ['username']); @@ -872,7 +886,7 @@ public function theseUsersHaveBeenInitialized(TableNode $table):void { * * @return ResponseInterface */ - public function getAllGroups():ResponseInterface { + public function getAllGroups(): ResponseInterface { $fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/groups"; return HttpRequestHelper::get( $fullUrl, @@ -888,7 +902,7 @@ public function getAllGroups():ResponseInterface { * * @return void */ - public function userGetsAllTheGroupsOfUser(string $user, string $otherUser):void { + public function userGetsAllTheGroupsOfUser(string $user, string $otherUser): void { $actualOtherUser = $this->getActualUsername($otherUser); $fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/users/$actualOtherUser/groups"; $actualUser = $this->getActualUsername($user); @@ -909,7 +923,7 @@ public function userGetsAllTheGroupsOfUser(string $user, string $otherUser):void * @return void * @throws Exception */ - public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user):void { + public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user): void { $this->featureContext->setResponse( $this->userGetsTheListOfAllUsers($user) ); @@ -920,7 +934,7 @@ public function userGetsTheListOfAllUsersUsingTheProvisioningApi(string $user):v * * @return ResponseInterface */ - public function userGetsTheListOfAllUsers(string $user):ResponseInterface { + public function userGetsTheListOfAllUsers(string $user): ResponseInterface { $fullUrl = $this->getBaseUrl() . "/ocs/v$this->ocsApiVersion.php/cloud/users"; $actualUser = $this->getActualUsername($user); $actualPassword = $this->getUserPassword($actualUser); @@ -941,7 +955,7 @@ public function userGetsTheListOfAllUsers(string $user):ResponseInterface { * * @return void */ - public function initializeUser(string $user, string $password):void { + public function initializeUser(string $user, string $password): void { $url = $this->getBaseUrl() . "/graph/v1.0/users/$user"; if (OcisHelper::isTestingOnReva()) { @@ -979,7 +993,7 @@ public function addUserToCreatedUsersList( ?string $email = null, ?string $userId = null, bool $shouldExist = true - ):void { + ): void { $user = $this->getActualUsername($user); $normalizedUsername = $this->normalizeUsername($user); $userData = [ @@ -1021,7 +1035,7 @@ public function addUserToCreatedUsersList( public function rememberUserPassword( string $user, string $password - ):void { + ): void { $normalizedUsername = $this->normalizeUsername($user); if ($this->currentServer === 'LOCAL') { if (\array_key_exists($normalizedUsername, $this->createdUsers)) { @@ -1040,7 +1054,7 @@ public function rememberUserPassword( * * @return void */ - public function updateUsernameInCreatedUserList(string $oldUserName, string $newUserName) :void { + public function updateUsernameInCreatedUserList(string $oldUserName, string $newUserName): void { $normalizedUsername = $this->normalizeUsername($oldUserName); $normalizeNewUserName = $this->normalizeUsername($newUserName); if (\array_key_exists($normalizedUsername, $this->createdUsers)) { @@ -1064,7 +1078,7 @@ public function updateUsernameInCreatedUserList(string $oldUserName, string $new * * @return void */ - public function rememberThatUserIsNotExpectedToExist(string $user):void { + public function rememberThatUserIsNotExpectedToExist(string $user): void { $user = $this->getActualUsername($user); $normalizedUsername = $this->normalizeUsername($user); if (\array_key_exists($normalizedUsername, $this->createdUsers)) { @@ -1085,7 +1099,7 @@ public function rememberThatUserIsNotExpectedToExist(string $user):void { public function userHasBeenCreated( array $userData, string $byUser = null - ):void { + ): void { $userId = null; $user = $userData["userName"]; @@ -1167,7 +1181,7 @@ public function userHasBeenCreated( * @return void * @throws Exception */ - public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void { + public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group): void { $user = $this->getActualUsername($user); if (OcisHelper::isTestingOnReva()) { $this->response = UserHelper::removeUserFromGroup( @@ -1199,7 +1213,7 @@ public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, s * @return void * @throws Exception */ - public function theExtraGroupsShouldBe(TableNode $groupsList):void { + public function theExtraGroupsShouldBe(TableNode $groupsList): void { $this->verifyTableNodeColumnsCount($groupsList, 1); $groups = $groupsList->getRows(); $groupsSimplified = $this->simplifyArray($groups); @@ -1227,7 +1241,7 @@ public function theExtraGroupsShouldBe(TableNode $groupsList):void { * @return void * @throws Exception */ - public function cleanupGroup(string $group):void { + public function cleanupGroup(string $group): void { try { if ($this->isTestingWithLdap()) { $this->deleteLdapGroup($group); @@ -1259,7 +1273,7 @@ public function cleanupGroup(string $group):void { * @return bool * @throws JsonException */ - public function userExists(string $user):bool { + public function userExists(string $user): bool { $path = (!OcisHelper::isTestingOnReva()) ? "/graph/v1.0" : "/ocs/v2.php/cloud"; @@ -1294,7 +1308,7 @@ public function userExists(string $user):bool { * @return void * @throws Exception */ - public function userShouldBelongToGroup(string $user, string $group):void { + public function userShouldBelongToGroup(string $user, string $group): void { $user = $this->getActualUsername($user); if (OcisHelper::isTestingOnReva()) { $this->userGetsAllTheGroupsOfUser($this->getAdminUsername(), $user); @@ -1331,7 +1345,7 @@ public function userShouldBelongToGroup(string $user, string $group):void { * @return void * @throws Exception */ - public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode $table):void { + public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode $table): void { $this->verifyTableNodeColumns($table, ["username", "groupname"]); $rows = $table->getHash(); foreach ($rows as $row) { @@ -1366,7 +1380,7 @@ public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode * * @return void */ - public function groupShouldNotContainUser(string $group, string $username):void { + public function groupShouldNotContainUser(string $group, string $username): void { $username = $this->getActualUsername($username); $fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/groups/$group"; $response = HttpRequestHelper::get( @@ -1387,7 +1401,7 @@ public function groupShouldNotContainUser(string $group, string $username):void * @return void * @throws Exception */ - public function adminAddsUserToGroupUsingTheProvisioningApi(string $user, string $group):void { + public function adminAddsUserToGroupUsingTheProvisioningApi(string $user, string $group): void { $response = $this->graphContext->addUserToGroup($group, $user); $this->setResponse($response); } @@ -1401,7 +1415,7 @@ public function adminAddsUserToGroupUsingTheProvisioningApi(string $user, string * @return void * @throws Exception */ - public function userHasBeenAddedToGroup(string $user, string $group):void { + public function userHasBeenAddedToGroup(string $user, string $group): void { $user = $this->getActualUsername($user); if ($this->isTestingWithLdap()) { try { @@ -1428,7 +1442,7 @@ public function userHasBeenAddedToGroup(string $user, string $group):void { * @return void * @throws Exception */ - public function theFollowingUserHaveBeenAddedToTheFollowingGroup(TableNode $table):void { + public function theFollowingUserHaveBeenAddedToTheFollowingGroup(TableNode $table): void { $this->verifyTableNodeColumns($table, ['username', 'groupname']); foreach ($table as $row) { $user = $row['username']; @@ -1465,7 +1479,7 @@ public function addGroupToCreatedGroupsList( bool $shouldExist = true, bool $possibleToDelete = true, ?string $id = null - ):void { + ): void { $groupData = [ "shouldExist" => $shouldExist, "possibleToDelete" => $possibleToDelete @@ -1491,7 +1505,7 @@ public function addGroupToCreatedGroupsList( * * @return void */ - public function rememberThatGroupIsNotExpectedToExist(string $group):void { + public function rememberThatGroupIsNotExpectedToExist(string $group): void { if (\array_key_exists($group, $this->createdGroups)) { $this->createdGroups[$group]['shouldExist'] = false; $this->createdGroups[$group]['possibleToDelete'] = false; @@ -1507,7 +1521,7 @@ public function rememberThatGroupIsNotExpectedToExist(string $group):void { * @throws Exception * @throws GuzzleException */ - public function groupHasBeenCreated(string $group):void { + public function groupHasBeenCreated(string $group): void { $this->createTheGroup($group); Assert::assertTrue( $this->groupExists($group), @@ -1524,7 +1538,7 @@ public function groupHasBeenCreated(string $group):void { * @return void * @throws Exception */ - public function theseGroupsHaveBeenCreated(TableNode $table):void { + public function theseGroupsHaveBeenCreated(TableNode $table): void { $this->verifyTableNodeColumns($table, ['groupname'], ['comment']); foreach ($table as $row) { $this->createTheGroup($row['groupname']); @@ -1540,7 +1554,7 @@ public function theseGroupsHaveBeenCreated(TableNode $table):void { * @return void * @throws Exception */ - public function createTheGroup(string $group, ?string $method = null):void { + public function createTheGroup(string $group, ?string $method = null): void { //guess yourself if ($method === null) { if ($this->isTestingWithLdap()) { @@ -1594,7 +1608,7 @@ public function setTheLdapAttributeOfTheEntryTo( string $entry, string $value, bool $append = false - ):void { + ): void { $ldapEntry = $this->ldap->getEntry($entry . "," . $this->ldapBaseDN); Laminas\Ldap\Attribute::setAttribute($ldapEntry, $attribute, $value, $append); $this->ldap->update($entry . "," . $this->ldapBaseDN, $ldapEntry); @@ -1608,7 +1622,7 @@ public function setTheLdapAttributeOfTheEntryTo( * @return void * @throws Exception */ - public function addUserToLdapGroup(string $user, string $group, ?string $ou = null):void { + public function addUserToLdapGroup(string $user, string $group, ?string $ou = null): void { if ($ou === null) { $ou = $this->getLdapGroupsOU(); } @@ -1635,7 +1649,7 @@ public function addUserToLdapGroup(string $user, string $group, ?string $ou = nu * * @return void */ - public function deleteValueFromLdapAttribute(string $value, string $attribute, string $entry):void { + public function deleteValueFromLdapAttribute(string $value, string $attribute, string $entry): void { $this->ldap->deleteAttributes( $entry . "," . $this->ldapBaseDN, [$attribute => [$value]] @@ -1650,7 +1664,7 @@ public function deleteValueFromLdapAttribute(string $value, string $attribute, s * @return void * @throws Exception */ - public function removeUserFromLdapGroup(string $user, string $group, ?string $ou = null):void { + public function removeUserFromLdapGroup(string $user, string $group, ?string $ou = null): void { if ($ou === null) { $ou = $this->getLdapGroupsOU(); } @@ -1675,7 +1689,7 @@ public function removeUserFromLdapGroup(string $user, string $group, ?string $ou * @return void * @throws Exception */ - public function deleteTheLdapEntry(string $entry):void { + public function deleteTheLdapEntry(string $entry): void { $this->ldap->delete($entry . "," . $this->ldapBaseDN); } @@ -1687,7 +1701,7 @@ public function deleteTheLdapEntry(string $entry):void { * @throws LdapException * @throws Exception */ - public function deleteLdapGroup(string $group, ?string $ou = null):void { + public function deleteLdapGroup(string $group, ?string $ou = null): void { if ($ou === null) { $ou = $this->getLdapGroupsOU(); } @@ -1706,7 +1720,7 @@ public function deleteLdapGroup(string $group, ?string $ou = null):void { * @return void * @throws Exception */ - public function deleteLdapUser(?string $username, ?string $ou = null):void { + public function deleteLdapUser(?string $username, ?string $ou = null): void { if (!\in_array($username, $this->ldapCreatedUsers)) { throw new Error( "User " . $username . " was not created using Ldap and does not exist as an Ldap User" @@ -1732,12 +1746,20 @@ public function deleteLdapUser(?string $username, ?string $ou = null):void { * @return void * @throws Exception */ - public function adminHasDisabledUserUsingTheProvisioningApi(?string $user):void { + public function adminHasDisabledUserUsingTheProvisioningApi(?string $user): void { $user = $this->getActualUsername($user); if (OcisHelper::isTestingOnReva()) { $response = $this->disableOrEnableUser($this->getAdminUsername(), $user, 'disable'); } else { - $response = $this->graphContext->editUserUsingTheGraphApi($this->getAdminUsername(), $user, null, null, null, null, false); + $response = $this->graphContext->editUserUsingTheGraphApi( + $this->getAdminUsername(), + $user, + null, + null, + null, + null, + false + ); } Assert::assertEquals( 200, @@ -1754,7 +1776,7 @@ public function adminHasDisabledUserUsingTheProvisioningApi(?string $user):void * @return void * @throws Exception */ - public function deleteUser(string $user):ResponseInterface { + public function deleteUser(string $user): ResponseInterface { // Always try to delete the user if (OcisHelper::isTestingOnReva()) { $response = UserHelper::deleteUser( @@ -1781,7 +1803,7 @@ public function deleteUser(string $user):ResponseInterface { * @throws Exception * @throws GuzzleException */ - public function groupHasBeenDeleted(string $group):void { + public function groupHasBeenDeleted(string $group): void { if ($this->isTestingWithLdap()) { $this->deleteLdapGroup($group); } else { @@ -1802,7 +1824,7 @@ public function groupHasBeenDeleted(string $group):void { * @throws Exception * @throws GuzzleException */ - public function groupExists(string $group):bool { + public function groupExists(string $group): bool { if ($this->isTestingWithLdap()) { $baseDN = $this->getLdapBaseDN(); $newDN = 'cn=' . $group . ',ou=' . $this->ldapGroupsOU . ',' . $baseDN; @@ -1834,7 +1856,7 @@ public function groupExists(string $group):bool { * @return void * @throws Exception */ - public function adminHasRemovedUserFromGroup(string $user, string $group):void { + public function adminHasRemovedUserFromGroup(string $user, string $group): void { $user = $this->getActualUsername($user); if ($this->isTestingWithLdap() && !$this->isLocalAdminGroup($group) @@ -1874,7 +1896,7 @@ public function adminHasRemovedUserFromGroup(string $user, string $group):void { * @return void * @throws Exception */ - public function theUsersShouldBe(TableNode $usersList):void { + public function theUsersShouldBe(TableNode $usersList): void { $this->verifyTableNodeColumnsCount($usersList, 1); $users = $usersList->getRows(); $usersSimplified = \array_map( @@ -1904,7 +1926,7 @@ function ($user) { * @return array * @throws Exception */ - public function getArrayOfUsersResponded(ResponseInterface $resp):array { + public function getArrayOfUsersResponded(ResponseInterface $resp): array { $listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->users[0]->element; return \json_decode(\json_encode($listCheckedElements), true); } @@ -1917,7 +1939,7 @@ public function getArrayOfUsersResponded(ResponseInterface $resp):array { * @return array * @throws Exception */ - public function getArrayOfGroupsResponded(ResponseInterface $resp):array { + public function getArrayOfGroupsResponded(ResponseInterface $resp): array { $listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->groups[0]->element; return \json_decode(\json_encode($listCheckedElements), true); @@ -1931,7 +1953,7 @@ public function getArrayOfGroupsResponded(ResponseInterface $resp):array { * @return array * @throws Exception */ - public function getArrayOfAppsResponded(ResponseInterface $resp):array { + public function getArrayOfAppsResponded(ResponseInterface $resp): array { $listCheckedElements = HttpRequestHelper::getResponseXml($resp, __METHOD__)->data[0]->apps[0]->element; return \json_decode(\json_encode($listCheckedElements), true); } @@ -1942,7 +1964,7 @@ public function getArrayOfAppsResponded(ResponseInterface $resp):array { * @return void * @throws Exception */ - public function theApiShouldNotReturnAnyData():void { + public function theApiShouldNotReturnAnyData(): void { $responseData = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; Assert::assertEmpty( $responseData, @@ -1956,7 +1978,7 @@ public function theApiShouldNotReturnAnyData():void { * @return void * @throws Exception */ - public function afterScenario():void { + public function afterScenario(): void { if (OcisHelper::isTestingOnReva()) { OcisHelper::deleteRevaUserData($this->getCreatedUsers()); } @@ -1973,7 +1995,7 @@ public function afterScenario():void { * @return void * @throws Exception */ - public function cleanupDatabaseUsers():void { + public function cleanupDatabaseUsers(): void { $previousServer = $this->currentServer; $this->usingServer('LOCAL'); foreach ($this->createdUsers as $userData) { @@ -2003,7 +2025,7 @@ public function cleanupDatabaseUsers():void { * @return void * @throws Exception */ - public function cleanupDatabaseGroups():void { + public function cleanupDatabaseGroups(): void { $previousServer = $this->currentServer; $this->usingServer('LOCAL'); foreach ($this->createdGroups as $group => $groupData) { @@ -2036,7 +2058,7 @@ public function cleanupDatabaseGroups():void { * @return void * @throws Exception */ - public function rememberGroupsThatExistAtTheStartOfTheScenario():void { + public function rememberGroupsThatExistAtTheStartOfTheScenario(): void { $this->startingGroups = $this->getArrayOfGroupsResponded($this->getAllGroups()); } diff --git a/tests/acceptance/bootstrap/PublicWebDavContext.php b/tests/acceptance/bootstrap/PublicWebDavContext.php index e0c9dd5bff5..76a1f74f8d6 100644 --- a/tests/acceptance/bootstrap/PublicWebDavContext.php +++ b/tests/acceptance/bootstrap/PublicWebDavContext.php @@ -43,7 +43,7 @@ class PublicWebDavContext implements Context { * * @return ResponseInterface */ - public function downloadPublicFileWithRange(string $range, ?string $password = ""):ResponseInterface { + public function downloadPublicFileWithRange(string $range, ?string $password = ""): ResponseInterface { // In this case a single file has been shared as a public link. // Even if that file is somewhere down inside a folder(s), when // accessing it as a public link using the public webDAV API @@ -66,7 +66,7 @@ public function downloadPublicFileWithRange(string $range, ?string $password = " * * @return void */ - public function downloadPublicFile():void { + public function downloadPublicFile(): void { $response = $this->downloadPublicFileWithRange(""); $this->featureContext->setResponse($response); } @@ -79,7 +79,7 @@ public function downloadPublicFile():void { * * @return void */ - public function downloadPublicFileWithPassword(string $password):void { + public function downloadPublicFileWithPassword(string $password): void { $response = $this->downloadPublicFileWithRange("", $password); $this->featureContext->setResponse($response); } @@ -92,7 +92,10 @@ public function downloadPublicFileWithPassword(string $password):void { * * @return void */ - public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav(string $user, string $path): void { + public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebdav( + string $user, + string $path + ): void { $response = $this->downloadFromPublicLinkAsUser($path, $user); $this->featureContext->setResponse($response); } @@ -104,7 +107,9 @@ public function userTriesToDownloadFileFromPublicLinkUsingBasicAuthAndPublicWebd * * @return void */ - public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi(string $fileName):void { + public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePublicWebdavApi( + string $fileName + ): void { $response = $this->deleteFileFromPublicShare( $fileName ); @@ -119,7 +124,9 @@ public function thePublicDeletesFileFolderFromTheLastPublicLinkShareUsingThePubl * @return ResponseInterface */ public function deleteFileFromPublicShare(string $fileName, string $password = ""): ResponseInterface { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( WebDavHelper::DAV_VERSION_NEW, $token, @@ -151,7 +158,10 @@ public function deleteFileFromPublicShare(string $fileName, string $password = " * * @return void */ - public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void { + public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi( + string $file, + string $password + ): void { $response = $this->deleteFileFromPublicShare($file, $password); $this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response); } @@ -164,7 +174,10 @@ public function thePublicHasDeletedFileFromTheLastLinkShareWithPasswordUsingPubl * * @return void */ - public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi(string $file, string $password): void { + public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicWebdavApi( + string $file, + string $password + ): void { $this->featureContext->setResponse( $this->deleteFileFromPublicShare($file, $password) ); @@ -178,8 +191,14 @@ public function thePublicDeletesFileFromTheLastLinkShareWithPasswordUsingPublicW * * @return ResponseInterface */ - public function renameFileFromPublicShare(string $fileName, string $toFileName, ?string $password = ""):ResponseInterface { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + public function renameFileFromPublicShare( + string $fileName, + string $toFileName, + ?string $password = "" + ): ResponseInterface { + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( WebDavHelper::DAV_VERSION_NEW, $token, @@ -215,7 +234,11 @@ public function renameFileFromPublicShare(string $fileName, string $toFileName, * * @return void */ - public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi(string $fileName, string $toName, string $password):void { + public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswordAndOldPublicWebdavApi( + string $fileName, + string $toName, + string $password + ): void { $this->featureContext->setResponse( $this->renameFileFromPublicShare($fileName, $toName, $password) ); @@ -231,7 +254,10 @@ public function thePublicRenamesFileFromTheLastPublicShareUsingThePasswordPasswo * * @return void */ - public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword(string $path, string $password = ""):void { + public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword( + string $path, + string $password = "" + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -249,7 +275,9 @@ public function publicDownloadsFileFromInsideLastPublicSharedFolderWithPassword( */ public function downloadFromPublicLinkAsUser(string $path, string $user): ResponseInterface { $path = \ltrim($path, "/"); - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( $this->featureContext->getDavPathVersion(), @@ -281,7 +309,7 @@ public function downloadFileFromPublicFolder( string $password, string $range, bool $shareNg = false - ):ResponseInterface { + ): ResponseInterface { $path = \ltrim($path, "/"); $password = $this->featureContext->getActualPassword($password); if ($shareNg) { @@ -320,7 +348,7 @@ public function downloadFileFromPublicFolder( * * @return ResponseInterface */ - public function publicUploadFile(string $source):ResponseInterface { + public function publicUploadFile(string $source): ResponseInterface { return $this->publicUploadContent( \basename($source), '', @@ -344,7 +372,7 @@ public function publiclyCopyingFile( string $baseUrl, string $source, string $destination - ):ResponseInterface { + ): ResponseInterface { $fullSourceUrl = "$baseUrl/$source"; $fullDestUrl = WebDavHelper::sanitizeUrl( "$baseUrl/$destination" @@ -369,8 +397,10 @@ public function publiclyCopyingFile( * * @return void */ - public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination):void { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $destination): void { + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( WebDavHelper::DAV_VERSION_NEW, $token, @@ -395,7 +425,7 @@ public function thePublicCopiesFileUsingTheWebDAVApi(string $source, string $des * * @return ResponseInterface */ - public function publiclyUploadingContentAutoRename(string $filename, string $body = 'test'):ResponseInterface { + public function publiclyUploadingContentAutoRename(string $filename, string $body = 'test'): ResponseInterface { return $this->publicUploadContent($filename, '', $body, true); } @@ -407,7 +437,7 @@ public function publiclyUploadingContentAutoRename(string $filename, string $bod * * @return void */ - public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'):void { + public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'): void { $response = $this->publiclyUploadingContentAutoRename($filename, $body); $this->featureContext->setResponse($response); } @@ -420,7 +450,10 @@ public function thePublicUploadsFileWithContentWithAutoRenameMode(string $filena * * @return void */ - public function thePublicHasUploadedFileWithContentWithAutoRenameMode(string $filename, string $body = 'test'):void { + public function thePublicHasUploadedFileWithContentWithAutoRenameMode( + string $filename, + string $body = 'test' + ): void { $response = $this->publiclyUploadingContentAutoRename($filename, $body); $this->featureContext->theHTTPStatusCodeShouldBe([201, 204], "", $response); } @@ -436,7 +469,7 @@ public function publiclyUploadingContentWithPassword( string $filename, string $password = '', string $body = 'test', - ):ResponseInterface { + ): ResponseInterface { return $this->publicUploadContent( $filename, $password, @@ -455,7 +488,11 @@ public function publiclyUploadingContentWithPassword( * * @return void */ - public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi(string $filename, string $content = 'test', string $password = ''): void { + public function thePublicHasUploadedFileWithContentAndPasswordToLastLinkShareUsingPublicWebdavApi( + string $filename, + string $content = 'test', + string $password = '' + ): void { $response = $this->publiclyUploadingContentWithPassword( $filename, $password, @@ -477,7 +514,7 @@ public function thePublicUploadsFileWithPasswordAndContentUsingPublicWebDAVApi( string $filename, string $password, string $body, - ):void { + ): void { $response = $this->publiclyUploadingContentWithPassword( $filename, $password, @@ -494,7 +531,7 @@ public function thePublicUploadsFileWithPasswordAndContentUsingPublicWebDAVApi( * * @return void */ - public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filename, string $body):void { + public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filename, string $body): void { $response = $this->publicUploadContent($filename, '', $body); $this->featureContext->setResponse($response); } @@ -510,7 +547,7 @@ public function thePublicOverwritesFileWithContentUsingWebDavApi(string $filenam public function thePublicUploadsFileWithContentUsingThePublicWebDavApi( string $filename, string $body = 'test' - ):void { + ): void { $response = $this->publicUploadContent($filename, '', $body); $this->featureContext->setResponse($response); $this->featureContext->pushToLastStatusCodesArrays(); @@ -541,7 +578,7 @@ public function thePublicHasUploadedFileWithContent(string $filename, string $bo public function checkLastPublicSharedFileWithPasswordDownload( string $password, string $expectedContent - ):void { + ): void { $response = $this->downloadPublicFileWithRange( "", $password @@ -568,7 +605,7 @@ public function checkLastPublicSharedFileWithPasswordDownload( public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolder( string $path, string $expectedHttpCode = "401" - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, "", @@ -589,7 +626,7 @@ public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolder( public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPassword( string $path, string $password - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -613,7 +650,7 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPasswordAn string $path, string $password, string $content - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -638,7 +675,7 @@ public function shouldBeAbleToDownloadFileInsidePublicSharedFolderWithPasswordFo string $path, string $password, string $content - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -664,7 +701,7 @@ public function shouldNotBeAbleToDownloadFileInsidePublicSharedFolderWithPasswor string $path, string $password, string $expectedHttpCode = "401" - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -687,7 +724,7 @@ public function shouldNotBeAbleToDownloadFileWithPasswordForShareNg( string $path, string $password, string $expectedHttpCode = "401" - ):void { + ): void { $this->tryingToDownloadUsingWebDAVAPI( $path, "new", @@ -712,7 +749,7 @@ public function tryingToDownloadUsingWebDAVAPI( string $range = "", string $expectedHttpCode = "401", bool $shareNg = false - ):void { + ): void { $response = $this->downloadFileFromPublicFolder( $path, $password, @@ -734,7 +771,7 @@ public function tryingToDownloadUsingWebDAVAPI( public function publiclyUploadingShouldToSharedFileShouldFail( string $password, string $expectedHttpCode - ):void { + ): void { $filename = (string)$this->featureContext->getLastCreatedPublicShare()->file_target; $response = $this->publicUploadContent( @@ -756,7 +793,7 @@ public function publiclyUploadingShouldToSharedFileShouldFail( public function publiclyUploadingWithPasswordShouldNotWork( string $password, string $expectedHttpCode = null - ):void { + ): void { $response = $this->publicUploadContent( 'whateverfilefortesting.txt', $password @@ -779,7 +816,7 @@ public function publiclyUploadingWithPasswordShouldNotWork( public function publiclyUploadingIntoFolderWithPasswordShouldWork( string $filename, string $password - ):void { + ): void { $response = $this->publicUploadContent( $filename, $password @@ -796,7 +833,7 @@ public function publiclyUploadingIntoFolderWithPasswordShouldWork( * @return void * @throws Exception */ - public function publiclyUploadingShouldWork(string $password):void { + public function publiclyUploadingShouldWork(string $password): void { $path = "whateverfilefortesting-publicWebDAVAPI.txt"; $content = "test"; @@ -832,7 +869,7 @@ public function publiclyUploadingShouldWork(string $password):void { public function publiclyUploadingToPublicLinkSharedFileShouldWork( string $password, string $shouldOrNot, - ):void { + ): void { $content = "test"; $should = ($shouldOrNot !== "not"); $path = (string) $this->featureContext->getLastCreatedPublicShare()->path; @@ -880,7 +917,7 @@ public function publiclyUploadingToPublicLinkSharedFileShouldWork( public function thePublicUploadsFileToInsideLastLinkSharedFolderUsingThePublicWebdavApi( string $source, string $destination, - ):void { + ): void { $content = \file_get_contents( $this->featureContext->acceptanceTestsDirLocation() . $source ); @@ -906,7 +943,7 @@ public function thePublicUploadsFileToInsideLastLinkSharedFolderWithPasswordUsin string $source, string $destination, string $password - ):void { + ): void { $content = \file_get_contents( $this->featureContext->acceptanceTestsDirLocation() . $source ); @@ -932,7 +969,7 @@ public function thePublicUploadsFileToLastSharedFolderWithMtimeUsingTheWebdavApi string $fileName, string $password, string $mtime - ):void { + ): void { $mtime = new DateTime($mtime); $mtime = $mtime->format('U'); @@ -955,8 +992,10 @@ public function thePublicUploadsFileToLastSharedFolderWithMtimeUsingTheWebdavApi public function publicCreatesFolderUsingPassword( string $destination, string $password - ):ResponseInterface { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + ): ResponseInterface { + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( $this->featureContext->getDavPathVersion(), $token, @@ -990,7 +1029,7 @@ public function publicCreatesFolderUsingPassword( * * @return void */ - public function publicCreatesFolder(string $destination):void { + public function publicCreatesFolder(string $destination): void { $this->featureContext->setResponse($this->publicCreatesFolderUsingPassword($destination, '')); } @@ -1005,7 +1044,7 @@ public function publicCreatesFolder(string $destination):void { public function publicShouldBeAbleToCreateFolderWithPassword( string $foldername, string $password - ):void { + ): void { $response = $this->publicCreatesFolderUsingPassword($foldername, $password); $this->featureContext->theHTTPStatusCodeShouldBe(201, "", $response); } @@ -1023,7 +1062,7 @@ public function publicCreationOfFolderWithPasswordShouldFail( string $foldername, string $password, string $expectedHttpCode - ):void { + ): void { $response = $this->publicCreatesFolderUsingPassword($foldername, $password); $this->featureContext->theHTTPStatusCodeShouldBe( $expectedHttpCode, @@ -1045,8 +1084,10 @@ public function publicCreationOfFolderWithPasswordShouldFail( public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe( string $fileName, string $mtime - ):void { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + ): void { + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $baseUrl = $this->featureContext->getBaseUrl(); $mtime = \explode(" ", $mtime); \array_pop($mtime); @@ -1074,7 +1115,7 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldNotBe( string $fileName, string $mtime - ):void { + ): void { $token = $this->featureContext->getLastCreatedPublicShareToken(); $baseUrl = $this->featureContext->getBaseUrl(); Assert::assertNotEquals( @@ -1105,7 +1146,7 @@ public function publicUploadContent( string $body = 'test', bool $autoRename = false, array $additionalHeaders = [], - ):?ResponseInterface { + ): ?ResponseInterface { $password = $this->featureContext->getActualPassword($password); if ($this->featureContext->isUsingSharingNG()) { $token = $this->featureContext->shareNgGetLastCreatedLinkShareToken(); @@ -1157,7 +1198,7 @@ public function publicUploadContent( private function getUsernameForPublicWebdavApi( string $token, string $password - ):?string { + ): ?string { if ($password !== '') { $userName = 'public'; } else { @@ -1173,7 +1214,7 @@ private function getUsernameForPublicWebdavApi( * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -1189,7 +1230,7 @@ public function before(BeforeScenarioScope $scope):void { * @return void * @throws GuzzleException */ - public function publicSendsRequestToLastPublicShare(string $method, ?string $password = ''):void { + public function publicSendsRequestToLastPublicShare(string $method, ?string $password = ''): void { if ($method === "PROPFIND") { $body = ' @@ -1205,7 +1246,9 @@ public function publicSendsRequestToLastPublicShare(string $method, ?string $pas } else { $body = null; } - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath( WebDavHelper::DAV_VERSION_NEW, $token, diff --git a/tests/acceptance/bootstrap/SearchContext.php b/tests/acceptance/bootstrap/SearchContext.php index f5d1c864d46..d09e4af16a9 100644 --- a/tests/acceptance/bootstrap/SearchContext.php +++ b/tests/acceptance/bootstrap/SearchContext.php @@ -84,7 +84,11 @@ private function searchFiles( $spaceId = $this->featureContext->spacesContext->getSpaceIdByName($user, $scope); $pattern .= " scope:$spaceId"; } else { - $resourceID = $this->featureContext->spacesContext->getResourceId($user, $spaceName ?? "Personal", $scope); + $resourceID = $this->featureContext->spacesContext->getResourceId( + $user, + $spaceName ?? "Personal", + $scope + ); $pattern .= " scope:$resourceID"; } } diff --git a/tests/acceptance/bootstrap/SettingsContext.php b/tests/acceptance/bootstrap/SettingsContext.php index 5f40f16e0b4..ab5838526aa 100644 --- a/tests/acceptance/bootstrap/SettingsContext.php +++ b/tests/acceptance/bootstrap/SettingsContext.php @@ -263,7 +263,11 @@ public function userShouldHaveRole(string $user, string $role): void { $assignmentResponse = $this->featureContext->getJsonDecodedResponseBodyContent($response); if (isset($assignmentResponse->assignments[0]->roleId)) { $actualRoleId = $assignmentResponse->assignments[0]->roleId; - Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $actualRoleId, "user $user has no role $role"); + Assert::assertEquals( + $this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), + $actualRoleId, + "user $user has no role $role" + ); } else { Assert::fail("Response should contain user role but not found.\n" . json_encode($assignmentResponse)); } @@ -279,8 +283,14 @@ public function userShouldHaveRole(string $user, string $role): void { * @throws Exception */ public function theSettingApiResponseShouldHaveTheRole(string $role): void { - $assignmentRoleId = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())["assignments"][0]["roleId"]; - Assert::assertEquals($this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), $assignmentRoleId, "user has no role $role"); + $assignmentRoleId = $this->featureContext->getJsonDecodedResponse( + $this->featureContext->getResponse() + )["assignments"][0]["roleId"]; + Assert::assertEquals( + $this->getRoleIdByRoleName($this->featureContext->getAdminUserName(), $role), + $assignmentRoleId, + "user has no role $role" + ); } /** diff --git a/tests/acceptance/bootstrap/ShareesContext.php b/tests/acceptance/bootstrap/ShareesContext.php index 1a20483772a..b5fac502fa7 100644 --- a/tests/acceptance/bootstrap/ShareesContext.php +++ b/tests/acceptance/bootstrap/ShareesContext.php @@ -46,7 +46,7 @@ class ShareesContext implements Context { * * @return void */ - public function theUserGetsTheShareesWithParameters(TableNode $body):void { + public function theUserGetsTheShareesWithParameters(TableNode $body): void { $this->featureContext->setResponse( $this->getShareesWithParameters( $this->featureContext->getCurrentUser(), @@ -63,7 +63,7 @@ public function theUserGetsTheShareesWithParameters(TableNode $body):void { * * @return void */ - public function userGetsTheShareesWithParameters(string $user, TableNode $body):void { + public function userGetsTheShareesWithParameters(string $user, TableNode $body): void { $this->featureContext->setResponse( $this->getShareesWithParameters( $user, @@ -81,7 +81,7 @@ public function userGetsTheShareesWithParameters(string $user, TableNode $body): * @return void * @throws Exception */ - public function theShareesReturnedShouldBe(string $shareeType, TableNode $shareesList):void { + public function theShareesReturnedShouldBe(string $shareeType, TableNode $shareesList): void { $this->featureContext->verifyTableNodeColumnsCount($shareesList, 4); $sharees = $shareesList->getRows(); $respondedArray = $this->getArrayOfShareesResponded( @@ -104,7 +104,7 @@ public function theShareesReturnedShouldBe(string $shareeType, TableNode $sharee * @return void * @throws Exception */ - public function theShareesReturnedShouldInclude(string $shareeType, TableNode $shareesList):void { + public function theShareesReturnedShouldInclude(string $shareeType, TableNode $shareesList): void { $this->featureContext->verifyTableNodeColumnsCount($shareesList, 3); $sharees = $shareesList->getRows(); $respondedArray = $this->getArrayOfShareesResponded( @@ -127,7 +127,7 @@ public function theShareesReturnedShouldInclude(string $shareeType, TableNode $s * * @return void */ - public function theShareesReturnedShouldBeEmpty(string $shareeType):void { + public function theShareesReturnedShouldBeEmpty(string $shareeType): void { $respondedArray = $this->getArrayOfShareesResponded( $this->featureContext->getResponse(), $shareeType @@ -155,7 +155,7 @@ public function theShareesReturnedShouldBeEmpty(string $shareeType):void { public function getArrayOfShareesResponded( ResponseInterface $response, string $shareeType - ):array { + ): array { $elements = HttpRequestHelper::getResponseXml($response, __METHOD__)->data; $elements = \json_decode(\json_encode($elements), true); if (\strpos($shareeType, 'exact ') === 0) { @@ -229,7 +229,7 @@ public function getShareesWithParameters(string $user, TableNode $body): Respons * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context diff --git a/tests/acceptance/bootstrap/Sharing.php b/tests/acceptance/bootstrap/Sharing.php index 6d3091b5ea5..b2250d3d522 100755 --- a/tests/acceptance/bootstrap/Sharing.php +++ b/tests/acceptance/bootstrap/Sharing.php @@ -90,14 +90,14 @@ trait Sharing { /** * @return string */ - public function getLastCreatedPublicShareToken():string { + public function getLastCreatedPublicShareToken(): string { return (string) $this->getLastCreatedPublicShare()->token; } /** * @return SimpleXMLElement|null */ - public function getLastCreatedPublicShare():?SimpleXMLElement { + public function getLastCreatedPublicShare(): ?SimpleXMLElement { return \end($this->createdPublicShares); } @@ -122,7 +122,7 @@ public function shareNgAddToCreatedLinkShares(ResponseInterface $response): void /** * @return ResponseInterface|null */ - public function shareNgGetLastCreatedLinkShare():?ResponseInterface { + public function shareNgGetLastCreatedLinkShare(): ?ResponseInterface { return \end($this->shareNgCreatedLinkShares); } @@ -138,7 +138,7 @@ public function shareNgAddToCreatedUserGroupShares(ResponseInterface $response): /** * @return ResponseInterface|null */ - public function shareNgGetLastCreatedUserGroupShare():?ResponseInterface { + public function shareNgGetLastCreatedUserGroupShare(): ?ResponseInterface { return \end($this->shareNgCreatedUserGroupShares); } @@ -169,7 +169,7 @@ public function getLastCreatedUserGroupShare(): SimpleXMLElement { /** * @return void */ - public function emptyCreatedPublicShares():void { + public function emptyCreatedPublicShares(): void { $this->createdPublicShares = []; } @@ -183,7 +183,7 @@ public function emptyCreatedUserGroupShares(): void { /** * @return float|null */ - public function getLocalLastShareTime():?float { + public function getLocalLastShareTime(): ?float { return $this->localLastShareTime; } @@ -192,7 +192,7 @@ public function getLocalLastShareTime():?float { * * @return string */ - public function getSharesEndpointPath(?string $postfix = ''):string { + public function getSharesEndpointPath(?string $postfix = ''): string { return "/apps/files_sharing/api/v$this->sharingApiVersion/shares$postfix"; } @@ -213,7 +213,11 @@ public function shareNgGetLastCreatedLinkShareID(): string { public function shareNgGetLastCreatedLinkShareToken(): string { $lastResponse = $this->shareNgGetLastCreatedLinkShare(); if (!isset($this->getJsonDecodedResponse($lastResponse)['link']['webUrl'])) { - throw new Error('Response did not contain share id ' . $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'] . ' for the created public link'); + throw new Error( + 'Response did not contain share id ' + . $this->getJsonDecodedResponse($lastResponse)['link']['webUrl'] + . ' for the created public link' + ); } $last_created_link_webURL = $this->getJsonDecodedResponse($lastResponse)['link']['webUrl']; return substr(strrchr($last_created_link_webURL, "/"), 1); @@ -237,7 +241,7 @@ public function shareNgGetLastCreatedUserGroupShareID(): string { * * @return string[] */ - private function splitPermissionsString(string $str):array { + private function splitPermissionsString(string $str): array { $str = \trim($str); $permissions = \array_map('trim', \explode(',', $str)); @@ -270,7 +274,7 @@ private function splitPermissionsString(string $str):array { * * @throws Exception */ - public function getServerShareTimeFromLastResponse():int { + public function getServerShareTimeFromLastResponse(): int { $stime = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->xpath("//stime"); if ($stime) { return (int) $stime[0]; @@ -281,7 +285,7 @@ public function getServerShareTimeFromLastResponse():int { /** * @return void */ - private function waitToCreateShare():void { + private function waitToCreateShare(): void { if (($this->localLastShareTime !== null) && ((\microtime(true) - $this->localLastShareTime) < 1) ) { @@ -341,8 +345,14 @@ public function createShareWithSettings(string $user, ?TableNode $body): Respons $bodyRows['name'] = \array_key_exists('name', $bodyRows) ? $bodyRows['name'] : null; $bodyRows['shareWith'] = \array_key_exists('shareWith', $bodyRows) ? $bodyRows['shareWith'] : null; $bodyRows['shareWith'] = $this->getActualUsername($bodyRows['shareWith']); - $bodyRows['publicUpload'] = \array_key_exists('publicUpload', $bodyRows) ? $bodyRows['publicUpload'] === 'true' : null; - $bodyRows['password'] = \array_key_exists('password', $bodyRows) ? $this->getActualPassword($bodyRows['password']) : null; + $bodyRows['publicUpload'] = \array_key_exists( + 'publicUpload', + $bodyRows + ) ? $bodyRows['publicUpload'] === 'true' : null; + $bodyRows['password'] = \array_key_exists( + 'password', + $bodyRows + ) ? $this->getActualPassword($bodyRows['password']) : null; if (\array_key_exists('permissions', $bodyRows)) { if (\is_numeric($bodyRows['permissions'])) { @@ -390,7 +400,7 @@ public function createShareWithSettings(string $user, ?TableNode $body): Respons * @return void * @throws Exception */ - public function userCreatesAShareWithSettings(string $user, ?TableNode $body):void { + public function userCreatesAShareWithSettings(string $user, ?TableNode $body): void { $user = $this->getActualUsername($user); $response = $this->createShareWithSettings( $user, @@ -441,7 +451,7 @@ public function createPublicLinkShare(string $user, TableNode $body): ResponseIn * @return void * @throws Exception */ - public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body):void { + public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body): void { $this->setResponse($this->createPublicLinkShare($user, $body)); $this->pushToLastStatusCodesArrays(); } @@ -455,7 +465,7 @@ public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode * @return void * @throws Exception */ - public function userHasCreatedAPublicLinkShareWithSettings(string $user, TableNode $body):void { + public function userHasCreatedAPublicLinkShareWithSettings(string $user, TableNode $body): void { $response = $this->createPublicLinkShare($user, $body); $this->theHTTPStatusCodeShouldBe(200, "", $response); $this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response); @@ -470,7 +480,7 @@ public function userHasCreatedAPublicLinkShareWithSettings(string $user, TableNo * @return void * @throws Exception */ - public function theUserCreatesAPublicLinkShareWithSettings(TableNode $body):void { + public function theUserCreatesAPublicLinkShareWithSettings(TableNode $body): void { $this->setResponse($this->createPublicLinkShare($this->currentUser, $body)); $this->pushToLastStatusCodesArrays(); } @@ -483,7 +493,7 @@ public function theUserCreatesAPublicLinkShareWithSettings(TableNode $body):void * @return void * @throws Exception */ - public function theUserHasCreatedAPublicLinkShareWithSettings(TableNode $body):void { + public function theUserHasCreatedAPublicLinkShareWithSettings(TableNode $body): void { $response = $this->createPublicLinkShare($this->currentUser, $body); $this->theHTTPStatusCodeShouldBe(200, "", $response); $this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response); @@ -530,7 +540,7 @@ public function createAPublicShare( * * @return void */ - public function userCreatesAPublicLinkShareOf(string $user, string $path):void { + public function userCreatesAPublicLinkShareOf(string $user, string $path): void { $response = $this->createAPublicShare($user, $path); $this->setResponse($response); } @@ -543,7 +553,7 @@ public function userCreatesAPublicLinkShareOf(string $user, string $path):void { * * @return void */ - public function userHasCreatedAPublicLinkShareOf(string $user, string $path):void { + public function userHasCreatedAPublicLinkShareOf(string $user, string $path): void { $response = $this->createAPublicShare($user, $path); $this->theHTTPStatusCodeShouldBe(200, "", $response); $this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response); @@ -562,7 +572,7 @@ public function userCreatesAPublicLinkShareOfWithPermission( string $user, string $path, $permissions - ):void { + ): void { $response = $this->createAPublicShare($user, $path, true, null, $permissions); $this->setResponse($response); } @@ -580,7 +590,7 @@ public function userHasCreatedAPublicLinkShareOfWithPermission( string $user, string $path, $permissions - ):void { + ): void { $response = $this->createAPublicShare($user, $path, true, null, $permissions); $this->theHTTPStatusCodeShouldBe(200, "", $response); $this->ocsContext->theOCSStatusCodeShouldBe("100,200", "", $response); @@ -597,7 +607,7 @@ public function createPublicLinkShareOfResourceWithExpiry( string $user, string $path, string $expiryDate - ):void { + ): void { $this->createAPublicShare( $user, $path, @@ -622,7 +632,7 @@ public function userCreatesAPublicLinkShareOfWithExpiry( string $user, string $path, string $expiryDate - ):void { + ): void { $this->createPublicLinkShareOfResourceWithExpiry( $user, $path, @@ -643,7 +653,7 @@ public function userHasCreatedAPublicLinkShareOfWithExpiry( string $user, string $path, string $expiryDate - ):void { + ): void { $this->createPublicLinkShareOfResourceWithExpiry( $user, $path, @@ -661,7 +671,7 @@ public function userHasCreatedAPublicLinkShareOfWithExpiry( * @return void * @throws Exception */ - public function shouldNotBeAbleToCreatePublicLinkShare(string $sharer, string $filepath):void { + public function shouldNotBeAbleToCreatePublicLinkShare(string $sharer, string $filepath): void { $this->createAPublicShare($sharer, $filepath); Assert::assertEquals( 404, @@ -679,7 +689,7 @@ public function shouldNotBeAbleToCreatePublicLinkShare(string $sharer, string $f * @return ResponseInterface * @throws Exception */ - public function updateLastShareByCurrentUser(?TableNode $body):ResponseInterface { + public function updateLastShareByCurrentUser(?TableNode $body): ResponseInterface { return $this->updateLastShareWithSettings($this->currentUser, $body); } @@ -691,7 +701,7 @@ public function updateLastShareByCurrentUser(?TableNode $body):ResponseInterface * @return void * @throws Exception */ - public function theUserUpdatesTheLastShareWith(?TableNode $body):void { + public function theUserUpdatesTheLastShareWith(?TableNode $body): void { $this->setResponse($this->updateLastShareByCurrentUser($body)); } @@ -703,7 +713,7 @@ public function theUserUpdatesTheLastShareWith(?TableNode $body):void { * @return void * @throws Exception */ - public function theUserHasUpdatedTheLastShareWith(?TableNode $body):void { + public function theUserHasUpdatedTheLastShareWith(?TableNode $body): void { $response = $this->updateLastShareByCurrentUser($body); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } @@ -718,7 +728,8 @@ public function theUserHasUpdatedTheLastShareWith(?TableNode $body):void { */ public function getLastCreatedUserGroupShareId(?string $user = null): string { if ($user === null) { - $shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id; + $shareId = $this->isUsingSharingNG() + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShare()->id; return (string) $shareId; } $createdShares = $this->getCreatedUserGroupShares(); @@ -742,14 +753,16 @@ public function updateLastShareWithSettings( ?TableNode $body, ?string $shareOwner = null, ?bool $updateLastPublicLink = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); if ($updateLastPublicLink) { - $share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; + $share_id = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; } else { if ($shareOwner === null) { - $share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + $share_id = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); } else { $share_id = $this->getLastCreatedUserGroupShareId($shareOwner); } @@ -794,7 +807,7 @@ public function updateLastShareWithSettings( * @return void * @throws Exception */ - public function userUpdatesTheLastShareWith(string $user, ?TableNode $body):void { + public function userUpdatesTheLastShareWith(string $user, ?TableNode $body): void { $this->setResponse($this->updateLastShareWithSettings($user, $body)); $this->pushToLastStatusCodesArrays(); } @@ -808,7 +821,7 @@ public function userUpdatesTheLastShareWith(string $user, ?TableNode $body):void * @return void * @throws Exception */ - public function userUpdatesTheLastPublicLinkShareWith(string $user, ?TableNode $body):void { + public function userUpdatesTheLastPublicLinkShareWith(string $user, ?TableNode $body): void { $this->response = $this->updateLastShareWithSettings($user, $body, null, true); $this->pushToLastStatusCodesArrays(); } @@ -822,7 +835,7 @@ public function userUpdatesTheLastPublicLinkShareWith(string $user, ?TableNode $ * @return void * @throws Exception */ - public function userHasUpdatedTheLastShareWith(string $user, ?TableNode $body):void { + public function userHasUpdatedTheLastShareWith(string $user, ?TableNode $body): void { $response = $this->updateLastShareWithSettings($user, $body); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } @@ -836,7 +849,7 @@ public function userHasUpdatedTheLastShareWith(string $user, ?TableNode $body):v * @return void * @throws Exception */ - public function userHasUpdatedTheLastPublicLinkShareWith(string $user, ?TableNode $body):void { + public function userHasUpdatedTheLastPublicLinkShareWith(string $user, ?TableNode $body): void { $response = $this->updateLastShareWithSettings($user, $body, null, true); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } @@ -851,7 +864,7 @@ public function userHasUpdatedTheLastPublicLinkShareWith(string $user, ?TableNod * @return void * @throws Exception */ - public function userHasUpdatedTheLastShareOfWith(string $user, string $shareOwner, ?TableNode $body):void { + public function userHasUpdatedTheLastShareOfWith(string $user, string $shareOwner, ?TableNode $body): void { $response = $this->updateLastShareWithSettings($user, $body, $shareOwner); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); if ($this->ocsApiVersion == 1) { @@ -951,7 +964,7 @@ public function doesFieldValueMatchExpectedContent( string $value, string $contentExpected, bool $expectSuccess = true - ):bool { + ): bool { if (($contentExpected === "ANY_VALUE") || (($contentExpected === "A_TOKEN") && (\strlen($value) === 15)) || (($contentExpected === "A_NUMBER") && \is_numeric($value)) @@ -979,7 +992,12 @@ public function doesFieldValueMatchExpectedContent( * @return bool * @throws Exception */ - public function isFieldInResponse(string $field, ?string $contentExpected, bool $expectSuccess = true, ?SimpleXMLElement $data = null):bool { + public function isFieldInResponse( + string $field, + ?string $contentExpected, + bool $expectSuccess = true, + ?SimpleXMLElement $data = null + ): bool { if ($data === null) { $data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; } @@ -1052,7 +1070,7 @@ public function isFieldInResponse(string $field, ?string $contentExpected, bool * * @return void */ - public function checkNoFilesFoldersInResponse():void { + public function checkNoFilesFoldersInResponse(): void { $data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; Assert::assertIsObject($data, __METHOD__ . " data not found in response XML"); Assert::assertCount(0, $data); @@ -1065,7 +1083,7 @@ public function checkNoFilesFoldersInResponse():void { * * @return void */ - public function checkCountFilesFoldersInResponse(string $count):void { + public function checkCountFilesFoldersInResponse(string $count): void { $count = (int) $count; $data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; Assert::assertIsObject($data, __METHOD__ . " data not found in response XML"); @@ -1080,7 +1098,7 @@ public function checkCountFilesFoldersInResponse(string $count):void { * @return void * @throws Exception */ - public function checkSharedFileInResponse(string $filename):void { + public function checkSharedFileInResponse(string $filename): void { $filename = "/" . \ltrim($filename, '/'); Assert::assertTrue( $this->isFieldInResponse('file_target', "$filename"), @@ -1096,7 +1114,7 @@ public function checkSharedFileInResponse(string $filename):void { * @return void * @throws Exception */ - public function checkSharedFileNotInResponse(string $filename):void { + public function checkSharedFileNotInResponse(string $filename): void { $filename = "/" . \ltrim($filename, '/'); Assert::assertFalse( $this->isFieldInResponse('file_target', "$filename", false), @@ -1112,7 +1130,7 @@ public function checkSharedFileNotInResponse(string $filename):void { * @return void * @throws Exception */ - public function checkSharedFileAsPathInResponse(string $filename):void { + public function checkSharedFileAsPathInResponse(string $filename): void { $filename = "/" . \ltrim($filename, '/'); Assert::assertTrue( $this->isFieldInResponse('path', "$filename"), @@ -1128,7 +1146,7 @@ public function checkSharedFileAsPathInResponse(string $filename):void { * @return void * @throws Exception */ - public function checkSharedFileAsPathNotInResponse(string $filename):void { + public function checkSharedFileAsPathNotInResponse(string $filename): void { $filename = "/" . \ltrim($filename, '/'); Assert::assertFalse( $this->isFieldInResponse('path', "$filename", false), @@ -1145,7 +1163,7 @@ public function checkSharedFileAsPathNotInResponse(string $filename):void { * @return void * @throws Exception */ - public function checkSharedUserOrGroupInResponse(string $type, string $user):void { + public function checkSharedUserOrGroupInResponse(string $type, string $user): void { if ($type === 'user') { $user = $this->getActualUsername($user); } @@ -1164,7 +1182,7 @@ public function checkSharedUserOrGroupInResponse(string $type, string $user):voi * @return void * @throws Exception */ - public function checkSharedUserOrGroupNotInResponse(string $userOrGroup):void { + public function checkSharedUserOrGroupNotInResponse(string $userOrGroup): void { Assert::assertFalse( $this->isFieldInResponse('share_with', "$userOrGroup", false), "'share_with' value '$userOrGroup' was unexpectedly found in response" @@ -1213,7 +1231,7 @@ public function userSharesFileWithUserUsingTheSharingApi( string $filepath, string $sharee, $permissions = null - ):void { + ): void { $response = $this->createAUserShare( $sharer, $filepath, @@ -1241,7 +1259,7 @@ public function userSharesTheFollowingFilesWithUserUsingTheSharingApi( string $sharee, TableNode $table, $permissions = null - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -1274,7 +1292,7 @@ public function userHasSharedFileWithUserUsingTheSharingApi( string $filepath, string $sharee, $permissions = null - ):void { + ): void { $response = $this->createAUserShare( $sharer, $filepath, @@ -1299,7 +1317,7 @@ public function userHasSharedFileWithTheAdministrator( string $sharer, string $filepath, $permissions = null - ):void { + ): void { $admin = $this->getAdminUsername(); $response = $this->createAUserShare( $sharer, @@ -1350,7 +1368,7 @@ public function theUserHasSharedFileWithUserUsingTheSharingApi( string $filepath, string $user2, $permissions = null - ):void { + ): void { $user2 = $this->getActualUsername($user2); $response = $this->createAUserShare( $this->getCurrentUser(), @@ -1376,7 +1394,7 @@ public function theUserSharesFileWithGroupUsingTheSharingApi( string $filepath, string $group, $permissions = null - ):void { + ): void { $response = $this->createAGroupShare( $this->currentUser, $filepath, @@ -1401,7 +1419,7 @@ public function theUserHasSharedFileWithGroupUsingTheSharingApi( string $filepath, string $group, $permissions = null - ):void { + ): void { $response = $this->createAGroupShare( $this->currentUser, $filepath, @@ -1534,7 +1552,7 @@ public function userHasSharedFileWithGroupUsingTheSharingApi( * @return void * @throws Exception */ - public function userTriesToUpdateTheLastShareUsingTheSharingApiWith(string $user, ?TableNode $body):void { + public function userTriesToUpdateTheLastShareUsingTheSharingApiWith(string $user, ?TableNode $body): void { $this->response = $this->updateLastShareWithSettings($user, $body); } @@ -1547,7 +1565,10 @@ public function userTriesToUpdateTheLastShareUsingTheSharingApiWith(string $user * @return void * @throws Exception */ - public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith(string $user, ?TableNode $body):void { + public function userTriesToUpdateTheLastPublicLinkShareUsingTheSharingApiWith( + string $user, + ?TableNode $body + ): void { $this->response = $this->updateLastShareWithSettings($user, $body, null, true); } @@ -1570,7 +1591,7 @@ public function userTriesToShareFileUsingTheSharingApi( string $userOrGroupShareType, string $sharee, $permissions = null - ):void { + ): void { $sharee = $this->getActualUsername($sharee); $response = $this->createShare( $sharer, @@ -1607,7 +1628,7 @@ public function userShouldBeAbleToShareUsingTheSharingApi( string $userOrGroupShareType, string $sharee, $permissions = null - ):void { + ): void { $sharee = $this->getActualUsername($sharee); $response = $this->createShare( $sharer, @@ -1631,7 +1652,7 @@ public function userShouldBeAbleToShareUsingTheSharingApi( * * @return void */ - public function theUserDeletesLastShareUsingTheSharingAPI():void { + public function theUserDeletesLastShareUsingTheSharingAPI(): void { $this->setResponse($this->deleteLastShareUsingSharingApiByCurrentUser()); } @@ -1640,7 +1661,7 @@ public function theUserDeletesLastShareUsingTheSharingAPI():void { * * @return void */ - public function theUserHasDeletedLastShareUsingTheSharingAPI():void { + public function theUserHasDeletedLastShareUsingTheSharingAPI(): void { $response = $this->deleteLastShareUsingSharingApiByCurrentUser(); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } @@ -1652,15 +1673,21 @@ public function theUserHasDeletedLastShareUsingTheSharingAPI():void { * * @return ResponseInterface */ - public function deleteLastShareUsingSharingApi(string $user, string $sharer = null, bool $deleteLastPublicLink = false):ResponseInterface { + public function deleteLastShareUsingSharingApi( + string $user, + string $sharer = null, + bool $deleteLastPublicLink = false + ): ResponseInterface { $user = $this->getActualUsername($user); if ($deleteLastPublicLink) { $shareId = (string) $this->getLastCreatedPublicShare()->id; } else { if ($sharer === null) { - $shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + $shareId = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); } else { - $shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer); + $shareId = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId($sharer); } } $url = $this->getSharesEndpointPath("/$shareId"); @@ -1674,7 +1701,7 @@ public function deleteLastShareUsingSharingApi(string $user, string $sharer = nu /** * @return ResponseInterface */ - public function deleteLastShareUsingSharingApiByCurrentUser():ResponseInterface { + public function deleteLastShareUsingSharingApiByCurrentUser(): ResponseInterface { return $this->deleteLastShareUsingSharingApi($this->currentUser); } @@ -1686,7 +1713,7 @@ public function deleteLastShareUsingSharingApiByCurrentUser():ResponseInterface * * @return void */ - public function userDeletesLastShareUsingTheSharingApi(string $user):void { + public function userDeletesLastShareUsingTheSharingApi(string $user): void { $this->setResponse($this->deleteLastShareUsingSharingApi($user)); $this->pushToLastStatusCodesArrays(); } @@ -1699,7 +1726,7 @@ public function userDeletesLastShareUsingTheSharingApi(string $user):void { * * @return void */ - public function userDeletesLastPublicLinkShareUsingTheSharingApi(string $user):void { + public function userDeletesLastPublicLinkShareUsingTheSharingApi(string $user): void { $this->setResponse($this->deleteLastShareUsingSharingApi($user, null, true)); $this->pushToLastStatusCodesArrays(); } @@ -1713,7 +1740,7 @@ public function userDeletesLastPublicLinkShareUsingTheSharingApi(string $user):v * * @return void */ - public function userDeletesLastShareOfUserUsingTheSharingApi(string $user, string $sharer):void { + public function userDeletesLastShareOfUserUsingTheSharingApi(string $user, string $sharer): void { $this->setResponse($this->deleteLastShareUsingSharingApi($user, $sharer)); $this->pushToLastStatusCodesArrays(); } @@ -1725,7 +1752,7 @@ public function userDeletesLastShareOfUserUsingTheSharingApi(string $user, strin * * @return void */ - public function userHasDeletedLastShareUsingTheSharingApi(string $user):void { + public function userHasDeletedLastShareUsingTheSharingApi(string $user): void { $response = $this->deleteLastShareUsingSharingApi($user); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } @@ -1739,9 +1766,11 @@ public function userHasDeletedLastShareUsingTheSharingApi(string $user):void { */ public function getLastShareInfo(string $user, string $shareType, ?string $language = null): ResponseInterface { if ($shareType !== "link") { - $shareId = $this->isUsingSharingNg() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + $shareId = $this->isUsingSharingNg() + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); } else { - $shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; + $shareId = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareID() : (string) $this->getLastCreatedPublicShare()->id; } if ($shareId === null) { throw new Exception( @@ -1761,7 +1790,7 @@ public function getLastShareInfo(string $user, string $shareType, ?string $langu * @return void * @throws Exception */ - public function userGetsInfoOfLastShareUsingTheSharingApi(string $user):void { + public function userGetsInfoOfLastShareUsingTheSharingApi(string $user): void { $response = $this->getLastShareInfo($user, "user"); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -1776,7 +1805,7 @@ public function userGetsInfoOfLastShareUsingTheSharingApi(string $user):void { * @return void * @throws Exception */ - public function userGetsInfoOfLastPublicLinkShareUsingTheSharingApi(string $user):void { + public function userGetsInfoOfLastPublicLinkShareUsingTheSharingApi(string $user): void { $response = $this->getLastShareInfo($user, "link"); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -1814,7 +1843,7 @@ public function asLastShareInfoAboutUserSharingWithUserShouldInclude( * * @return ResponseInterface */ - public function getShareData(string $user, string $share_id, ?string $language = null):ResponseInterface { + public function getShareData(string $user, string $share_id, ?string $language = null): ResponseInterface { $user = $this->getActualUsername($user); $url = $this->getSharesEndpointPath("/$share_id"); $headers = []; @@ -1836,7 +1865,7 @@ public function getShareData(string $user, string $share_id, ?string $language = * * @return ResponseInterface */ - public function getSharedWithMeShares(string $user):ResponseInterface { + public function getSharedWithMeShares(string $user): ResponseInterface { $user = $this->getActualUsername($user); $url = "/apps/files_sharing/api/v1/shares?shared_with_me=true"; return $this->ocsContext->sendRequestToOcsEndpoint( @@ -1853,7 +1882,7 @@ public function getSharedWithMeShares(string $user):ResponseInterface { * * @return void */ - public function userGetsAllTheSharesSharedWithHimUsingTheSharingApi(string $user):void { + public function userGetsAllTheSharesSharedWithHimUsingTheSharingApi(string $user): void { $this->setResponse($this->getSharedWithMeShares($user)); } @@ -1866,10 +1895,11 @@ public function userGetsAllTheSharesSharedWithHimUsingTheSharingApi(string $user * @return void * @throws Exception */ - public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table):void { + public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user, TableNode $table): void { $user = $this->getActualUsername($user); $this->verifyTableNodeRows($table, [], $this->shareResponseFields); - $share_id = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + $share_id = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); $response = $this->getShareData($user, $share_id); $this->theHTTPStatusCodeShouldBe( @@ -1898,7 +1928,11 @@ public function userGetsTheLastShareSharedWithHimUsingTheSharingApi(string $user * * @return void */ - public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi(string $user, string $pending, string $shareType):void { + public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi( + string $user, + string $pending, + string $shareType + ): void { $user = $this->getActualUsername($user); if ($pending === "pending") { $pendingClause = "&state=" . SharingHelper::SHARE_STATES['pending']; @@ -1931,7 +1965,10 @@ public function userGetsFilteredSharesSharedWithHimUsingTheSharingApi(string $us * * @return void */ - public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi(string $user, string $path):void { + public function userGetsAllSharesSharedWithHimFromFileOrFolderUsingTheProvisioningApi( + string $user, + string $path + ): void { $user = $this->getActualUsername($user); $url = "/apps/files_sharing/api/" . "v$this->sharingApiVersion/shares?shared_with_me=true&path=$path"; @@ -1975,7 +2012,7 @@ public function getAllShares( * * @return void */ - public function userGetsAllSharesSharedByHimUsingTheSharingApi(string $user):void { + public function userGetsAllSharesSharedByHimUsingTheSharingApi(string $user): void { $this->setResponse($this->getAllshares($user)); } @@ -1984,7 +2021,7 @@ public function userGetsAllSharesSharedByHimUsingTheSharingApi(string $user):voi * * @return void */ - public function theAdministratorGetsAllSharesSharedByHimUsingTheSharingApi():void { + public function theAdministratorGetsAllSharesSharedByHimUsingTheSharingApi(): void { $this->setResponse($this->getAllShares($this->getAdminUsername())); } @@ -1996,7 +2033,7 @@ public function theAdministratorGetsAllSharesSharedByHimUsingTheSharingApi():voi * * @return void */ - public function userGetsFilteredSharesSharedByHimUsingTheSharingApi(string $user, string $shareType):void { + public function userGetsFilteredSharesSharedByHimUsingTheSharingApi(string $user, string $shareType): void { if ($shareType === 'public link') { $shareType = 'public_link'; } @@ -2016,7 +2053,7 @@ public function userGetsFilteredSharesSharedByHimUsingTheSharingApi(string $user * * @return void */ - public function userGetsAllTheSharesFromTheFileUsingTheSharingApi(string $user, string $path):void { + public function userGetsAllTheSharesFromTheFileUsingTheSharingApi(string $user, string $path): void { $this->setResponse($this->getAllShares($user, "?path=$path")); } @@ -2031,7 +2068,7 @@ public function userGetsAllTheSharesFromTheFileUsingTheSharingApi(string $user, public function userGetsAllTheSharesWithResharesFromTheFileUsingTheSharingApi( string $user, string $path - ):void { + ): void { $this->setResponse($this->getAllShares($user, "?reshares=true&path=$path")); } @@ -2043,7 +2080,7 @@ public function userGetsAllTheSharesWithResharesFromTheFileUsingTheSharingApi( * * @return void */ - public function userGetsAllTheSharesInsideTheFolderUsingTheSharingApi(string $user, string $path):void { + public function userGetsAllTheSharesInsideTheFolderUsingTheSharingApi(string $user, string $path): void { $this->setResponse($this->getAllShares($user, "?path=$path&subfiles=true")); } @@ -2059,7 +2096,7 @@ public function userGetsAllTheSharesInsideTheFolderUsingTheSharingApi(string $us public function theResponseWhenUserGetsInfoOfLastPublicLinkShareShouldInclude( string $user, ?TableNode $body - ):void { + ): void { $user = $this->getActualUsername($user); $this->verifyTableNodeRows($body, [], $this->shareResponseFields); $this->getShareData($user, (string) $this->getLastCreatedPublicShare()->id); @@ -2089,7 +2126,7 @@ public function theResponseWhenUserGetsInfoOfLastPublicLinkShareShouldInclude( public function informationOfLastShareShouldInclude( string $user, TableNode $body - ):void { + ): void { $user = $this->getActualUsername($user); $shareId = $this->getLastCreatedUserGroupShareId($user); $this->getShareData($user, $shareId); @@ -2119,7 +2156,7 @@ public function theFieldsOfTheResponseForUserForResourceShouldInclude( string $fileName, string $type, TableNode $body - ):void { + ): void { $user = $this->getActualUsername($user); $this->verifyTableNodeColumnsCount($body, 2); $fileName = $fileName[0] === "/" ? $fileName : '/' . $fileName; @@ -2166,8 +2203,9 @@ public function theFieldsOfTheResponseForUserForResourceShouldInclude( * @return void * @throws Exception */ - public function checkingLastShareIDIsIncluded():void { - $shareId = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + public function checkingLastShareIDIsIncluded(): void { + $shareId = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); if (!$this->isFieldInResponse('id', $shareId)) { Assert::fail( "Share id $shareId not found in response" @@ -2181,8 +2219,9 @@ public function checkingLastShareIDIsIncluded():void { * @return void * @throws Exception */ - public function checkLastShareIDIsNotIncluded():void { - $shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + public function checkLastShareIDIsNotIncluded(): void { + $shareId = $this->isUsingSharingNG() + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); if ($this->isFieldInResponse('id', $shareId, false)) { Assert::fail( "Share id $shareId has been found in response" @@ -2196,7 +2235,7 @@ public function checkLastShareIDIsNotIncluded():void { * @return void * @throws Exception */ - public function checkLastPublicLinkShareIDIsNotIncluded():void { + public function checkLastPublicLinkShareIDIsNotIncluded(): void { $shareId = (string) $this->getLastCreatedPublicShare()->id; if ($this->isFieldInResponse('id', $shareId, false)) { Assert::fail( @@ -2211,7 +2250,7 @@ public function checkLastPublicLinkShareIDIsNotIncluded():void { * * @return void */ - public function responseShouldNotContainAnyShareIds(ResponseInterface $response):void { + public function responseShouldNotContainAnyShareIds(ResponseInterface $response): void { $data = HttpRequestHelper::getResponseXml($response, __METHOD__)->data[0]; $fieldIsSet = false; $receivedShareCount = 0; @@ -2243,10 +2282,11 @@ public function responseShouldNotContainAnyShareIds(ResponseInterface $response) * @return void * @throws Exception */ - public function userShouldNotSeeShareIdOfLastShare(string $user):void { + public function userShouldNotSeeShareIdOfLastShare(string $user): void { $response = $this->getSharedWithMeShares($user); $this->theHTTPStatusCodeShouldBe(200, "", $response); - $shareId = $this->isUsingSharingNG() ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); + $shareId = $this->isUsingSharingNG() + ? $this->shareNgGetLastCreatedUserGroupShareID() : $this->getLastCreatedUserGroupShareId(); if ($this->isFieldInResponse('id', $shareId, false)) { Assert::fail( "Share id $shareId has been found in response" @@ -2261,7 +2301,7 @@ public function userShouldNotSeeShareIdOfLastShare(string $user):void { * * @return void */ - public function userShouldNotHaveAnyReceivedShares(string $user):void { + public function userShouldNotHaveAnyReceivedShares(string $user): void { $response = $this->getSharedWithMeShares($user); $this->theHTTPStatusCodeShouldBe(200, "", $response); $this->responseShouldNotContainAnyShareIds($response); @@ -2274,7 +2314,7 @@ public function userShouldNotHaveAnyReceivedShares(string $user):void { * * @return void */ - public function checkingTheResponseEntriesCount(int $count):void { + public function checkingTheResponseEntriesCount(int $count): void { $actualCount = \count(HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]); Assert::assertEquals( $count, @@ -2292,7 +2332,7 @@ public function checkingTheResponseEntriesCount(int $count):void { * @return void * @throws Exception */ - public function checkFields(string $user, ?TableNode $body):void { + public function checkFields(string $user, ?TableNode $body): void { $this->checkTheFields($user, $body); } @@ -2303,7 +2343,7 @@ public function checkFields(string $user, ?TableNode $body):void { * * @return void */ - public function checkTheFields(string $user, ?TableNode $body, ?ResponseInterface $response = null):void { + public function checkTheFields(string $user, ?TableNode $body, ?ResponseInterface $response = null): void { $response = $response ?? $this->getResponse(); $data = HttpRequestHelper::getResponseXml($response, __METHOD__)->data[0]; $this->verifyTableNodeColumnsCount($body, 2); @@ -2342,7 +2382,7 @@ public function checkTheFields(string $user, ?TableNode $body, ?ResponseInterfac * @return void * @throws Exception */ - public function checkFieldsOfSpaceSharingResponse(string $user, string $space, ?TableNode $body):void { + public function checkFieldsOfSpaceSharingResponse(string $user, string $space, ?TableNode $body): void { $this->verifyTableNodeColumnsCount($body, 2); $bodyRows = $body->getRowsHash(); @@ -2406,7 +2446,7 @@ public function checkFieldsOfSpaceSharingResponse(string $user, string $space, ? * @return void * @throws Exception */ - public function checkFieldsOfLastResponseToUser(string $sharer, string $sharee, ?TableNode $body):void { + public function checkFieldsOfLastResponseToUser(string $sharer, string $sharee, ?TableNode $body): void { $this->checkTheFieldsOfLastResponseToUser($sharer, $sharee, $body); } @@ -2417,13 +2457,29 @@ public function checkFieldsOfLastResponseToUser(string $sharer, string $sharee, * * @return void */ - public function checkTheFieldsOfLastResponseToUser(string $sharer, string $sharee, ?TableNode $body):void { + public function checkTheFieldsOfLastResponseToUser(string $sharer, string $sharee, ?TableNode $body): void { $this->verifyTableNodeColumnsCount($body, 2); $bodyRows = $body->getRowsHash(); foreach ($bodyRows as $field => $value) { - if (\in_array($field, ["displayname_owner", "displayname_file_owner", "owner", "uid_owner", "uid_file_owner", "additional_info_owner", "additional_info_file_owner"])) { + if (\in_array( + $field, + [ + "displayname_owner", + "displayname_file_owner", + "owner", + "uid_owner", + "uid_file_owner", + "additional_info_owner", + "additional_info_file_owner" + ] + ) + ) { $value = $this->substituteInLineCodes($value, $sharer); - } elseif (\in_array($field, ["share_with", "share_with_displayname", "user", "share_with_additional_info"])) { + } elseif (\in_array( + $field, + ["share_with", "share_with_displayname", "user", "share_with_additional_info"] + ) + ) { $value = $this->substituteInLineCodes($value, $sharee); } $value = $this->replaceValuesFromTable($field, $value); @@ -2439,7 +2495,7 @@ public function checkTheFieldsOfLastResponseToUser(string $sharer, string $share * * @return void */ - public function theFieldsOfTheLastResponseShouldBeEmpty():void { + public function theFieldsOfTheLastResponseShouldBeEmpty(): void { $data = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; Assert::assertEquals( \count($data->element), @@ -2454,7 +2510,7 @@ public function theFieldsOfTheLastResponseShouldBeEmpty():void { * * @throws Exception */ - public function getSharingAttributesFromLastResponse():string { + public function getSharingAttributesFromLastResponse(): string { $responseXmlObject = HttpRequestHelper::getResponseXml($this->response, __METHOD__)->data[0]; $actualAttributesElement = $responseXmlObject->xpath('//attributes'); @@ -2479,7 +2535,7 @@ public function getSharingAttributesFromLastResponse():string { * @return void * @throws Exception */ - public function checkingAttributesInLastShareResponse(TableNode $attributes):void { + public function checkingAttributesInLastShareResponse(TableNode $attributes): void { $this->verifyTableNodeColumns($attributes, ['scope', 'key', 'enabled']); $attributes = $attributes->getHash(); @@ -2540,7 +2596,7 @@ function (&$value, $key) { * @return void * @throws Exception */ - public function userDownloadsFailWithMessage(string $fileName, string $user, PyStringNode $errorMessage):void { + public function userDownloadsFailWithMessage(string $fileName, string $user, PyStringNode $errorMessage): void { $user = $this->getActualUsername($user); $response = $this->downloadFileAsUserUsingPassword($user, $fileName); $receivedErrorMessage = HttpRequestHelper::getResponseXml($response, __METHOD__)->xpath('//s:message'); @@ -2561,7 +2617,7 @@ public function userDownloadsFailWithMessage(string $fileName, string $user, PyS * @return void * @throws Exception */ - public function checkFieldsNotInResponse(?TableNode $body):void { + public function checkFieldsNotInResponse(?TableNode $body): void { $this->verifyTableNodeColumnsCount($body, 2); $bodyRows = $body->getRowsHash(); @@ -2589,7 +2645,7 @@ public function checkFieldsNotInResponse(?TableNode $body):void { * * @return SimpleXMLElement */ - public function getShares(string $user, string $path):SimpleXMLElement { + public function getShares(string $user, string $path): SimpleXMLElement { $response = OcsApiHelper::sendRequest( $this->getBaseUrl(), $user, @@ -2613,7 +2669,7 @@ public function getShares(string $user, string $path):SimpleXMLElement { * @return void * @throws Exception */ - public function checkPublicShares(string $user, string $path, ?TableNode $TableNode):void { + public function checkPublicShares(string $user, string $path, ?TableNode $TableNode): void { $user = $this->getActualUsername($user); $response = $this->getShares($user, $path); @@ -2662,7 +2718,7 @@ public function checkPublicShares(string $user, string $path, ?TableNode $TableN * @return void * @throws Exception */ - public function checkPublicSharesAreEmpty(string $user, string $path):void { + public function checkPublicSharesAreEmpty(string $user, string $path): void { $user = $this->getActualUsername($user); $response = $this->getShares($user, $path); //It shouldn't have public shares @@ -2683,7 +2739,7 @@ public function checkPublicSharesAreEmpty(string $user, string $path):void { * * @return string|null */ - public function getPublicShareIDByName(string $user, string $path, string $name):?string { + public function getPublicShareIDByName(string $user, string $path, string $name): ?string { $response = $this->getShares($user, $path); foreach ($response as $elementResponded) { if ((string) $elementResponded->name[0] === $name) { @@ -2704,7 +2760,7 @@ public function deletePublicLinkShareUsingTheSharingApi( string $user, string $name, string $path - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $share_id = $this->getPublicShareIDByName($user, $path, $name); $url = $this->getSharesEndpointPath("/$share_id"); @@ -2728,7 +2784,7 @@ public function userDeletesPublicLinkShareNamedUsingTheSharingApi( string $user, string $name, string $path - ):void { + ): void { $response = $this->deletePublicLinkShareUsingTheSharingApi( $user, $name, @@ -2750,7 +2806,7 @@ public function userHasDeletedPublicLinkShareNamedUsingTheSharingApi( string $user, string $name, string $path - ):void { + ): void { $response = $this->deletePublicLinkShareUsingTheSharingApi( $user, $name, @@ -2768,7 +2824,13 @@ public function userHasDeletedPublicLinkShareNamedUsingTheSharingApi( * * @return ResponseInterface */ - public function reactToShareOfferedBy(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):ResponseInterface { + public function reactToShareOfferedBy( + string $user, + string $action, + string $share, + string $offeredBy, + ?string $state = '' + ): ResponseInterface { $user = $this->getActualUsername($user); $offeredBy = $this->getActualUsername($offeredBy); @@ -2830,7 +2892,13 @@ public function reactToShareOfferedBy(string $user, string $action, string $shar * @return void * @throws Exception */ - public function userReactsToShareOfferedBy(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):void { + public function userReactsToShareOfferedBy( + string $user, + string $action, + string $share, + string $offeredBy, + ?string $state = '' + ): void { $response = $this->reactToShareOfferedBy( $user, $action, @@ -2853,7 +2921,13 @@ public function userReactsToShareOfferedBy(string $user, string $action, string * @return void * @throws Exception */ - public function userAcceptsTheAlreadyAcceptedShareOfferedByUsingTheSharingApi(string $user, string $action, string $share, string $offeredBy, ?string $state = ''):void { + public function userAcceptsTheAlreadyAcceptedShareOfferedByUsingTheSharingApi( + string $user, + string $action, + string $share, + string $offeredBy, + ?string $state = '' + ): void { $response = $this->reactToShareOfferedBy( $user, $action, @@ -2875,7 +2949,12 @@ public function userAcceptsTheAlreadyAcceptedShareOfferedByUsingTheSharingApi(st * @return void * @throws Exception */ - public function userReactsToTheFollowingSharesOfferedBy(string $user, string $action, string $offeredBy, TableNode $table):void { + public function userReactsToTheFollowingSharesOfferedBy( + string $user, + string $action, + string $offeredBy, + TableNode $table + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -2902,7 +2981,7 @@ public function userReactsToTheFollowingSharesOfferedBy(string $user, string $ac * @return void * @throws Exception */ - public function userReactsToShareWithShareIDOfferedBy(string $user, string $action, string $share_id):void { + public function userReactsToShareWithShareIDOfferedBy(string $user, string $action, string $share_id): void { $user = $this->getActualUsername($user); $shareId = $this->substituteInLineCodes($share_id, $user); @@ -2935,7 +3014,12 @@ public function userReactsToShareWithShareIDOfferedBy(string $user, string $acti * @return void * @throws Exception */ - public function userHasReactedToShareOfferedBy(string $user, string $action, string $share, string $offeredBy):void { + public function userHasReactedToShareOfferedBy( + string $user, + string $action, + string $share, + string $offeredBy + ): void { $response = $this->reactToShareOfferedBy( $user, $action, @@ -2966,7 +3050,7 @@ public function userHasReactedToShareOfferedBy(string $user, string $action, str * @return void * @throws Exception */ - public function userAcceptsThePendingShareOfferedBy(string $user, string $share, string $offeredBy):void { + public function userAcceptsThePendingShareOfferedBy(string $user, string $share, string $offeredBy): void { $response = $this->reactToShareOfferedBy($user, 'accepts', $share, $offeredBy, 'pending'); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -3043,7 +3127,7 @@ public function userShouldBeAbleToAcceptShareOfferedBy( * @return void * @throws Exception */ - public function assertSharesOfUserAreInState(string $user, string $state, TableNode $table):void { + public function assertSharesOfUserAreInState(string $user, string $state, TableNode $table): void { $this->verifyTableNodeColumns($table, ["path"], $this->shareResponseFields); $usersShares = $this->getAllSharesSharedWithUser($user, $state); foreach ($table as $row) { @@ -3079,7 +3163,7 @@ public function assertSharesOfUserAreInState(string $user, string $state, TableN * @return void * @throws Exception */ - public function assertNoSharesOfUserAreInState(string $user, string $state):void { + public function assertNoSharesOfUserAreInState(string $user, string $state): void { $usersShares = $this->getAllSharesSharedWithUser($user, $state); Assert::assertEmpty( $usersShares, @@ -3141,7 +3225,7 @@ public function userUnsharesResourceSharedTo(string $sharer, string $path, strin * @return void * @throws Exception */ - public function assertThatNoSharesAreSharedWithUser(string $user):void { + public function assertThatNoSharesAreSharedWithUser(string $user): void { $usersShares = $this->getAllSharesSharedWithUser($user); Assert::assertEmpty( $usersShares, @@ -3157,7 +3241,10 @@ public function assertThatNoSharesAreSharedWithUser(string $user):void { * * @return ResponseInterface|null */ - public function userGetsTheLastShareWithTheShareIdUsingTheSharingApi(string $user, string $share_id): ?ResponseInterface { + public function userGetsTheLastShareWithTheShareIdUsingTheSharingApi( + string $user, + string $share_id + ): ?ResponseInterface { $user = $this->getActualUsername($user); $share_id = $this->substituteInLineCodes($share_id, $user); $url = $this->getSharesEndpointPath("/$share_id"); @@ -3228,7 +3315,7 @@ private function getAllSharesSharedWithUser(string $user, ?string $state = "all" * * @return ResponseInterface */ - public function getPublicPreviewOfFile(string $fileName, string $token):ResponseInterface { + public function getPublicPreviewOfFile(string $fileName, string $token): ResponseInterface { $baseUrl = $this->getBaseUrl(); $davPath = WebdavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files"); $url = "$baseUrl/$davPath/$fileName?preview=1"; @@ -3245,8 +3332,9 @@ public function getPublicPreviewOfFile(string $fileName, string $token):Response * * @return void */ - public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(string $path):void { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(string $path): void { + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $response = $this->getPublicPreviewOfFile($path, $token); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -3262,13 +3350,14 @@ public function thePublicAccessesThePreviewOfTheSharedFileUsingTheSharingApi(str */ public function thePublicAccessesThePreviewOfTheFollowingSharedFileUsingTheSharingApi( TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); $this->emptyLastHTTPStatusCodesArray(); $this->emptyLastOCSStatusCodesArray(); foreach ($paths as $path) { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $response = $this->getPublicPreviewOfFile($path["path"], $token); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -3286,7 +3375,7 @@ public function saveLastSharedPublicLinkShare( string $user, string $shareServer, ?string $password = "" - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $userPassword = $this->getPasswordForUser($user); @@ -3336,7 +3425,7 @@ public function saveLastSharedPublicLinkShare( * * @return void */ - public function userHasAddedPublicShareCreatedByUser(string $user, string $shareServer):void { + public function userHasAddedPublicShareCreatedByUser(string $user, string $shareServer): void { $this->saveLastSharedPublicLinkShare($user, $shareServer); $resBody = json_decode($this->response->getBody()->getContents()); @@ -3371,7 +3460,12 @@ public function userHasAddedPublicShareCreatedByUser(string $user, string $share * * @return array */ - public function preparePublicQuickLinkPayload(string $user, string $path, string $type, int $permissions = 1): array { + public function preparePublicQuickLinkPayload( + string $user, + string $path, + string $type, + int $permissions = 1 + ): array { return [ "permissions" => $permissions, "expireDate" => "", @@ -3400,7 +3494,7 @@ public function preparePublicQuickLinkPayload(string $user, string $path, string * @return void * @throws Exception */ - public function theUserHasCreatedAReadOnlyPublicLinkForFileFolder(string $user, string $type, string $path):void { + public function theUserHasCreatedAReadOnlyPublicLinkForFileFolder(string $user, string $type, string $path): void { $user = $this->getActualUsername($user); $userPassword = $this->getPasswordForUser($user); @@ -3426,7 +3520,7 @@ public function theUserHasCreatedAReadOnlyPublicLinkForFileFolder(string $user, * * @return void */ - public function userAddsPublicShareCreatedByUser(string $user, string $shareServer):void { + public function userAddsPublicShareCreatedByUser(string $user, string $shareServer): void { $this->setResponse($this->saveLastSharedPublicLinkShare($user, $shareServer)); } @@ -3436,7 +3530,7 @@ public function userAddsPublicShareCreatedByUser(string $user, string $shareServ * @return void * @throws ResponseInterface */ - public function expireLastCreatedPublicLinkShare():ResponseInterface { + public function expireLastCreatedPublicLinkShare(): ResponseInterface { $shareId = (string) $this->getLastCreatedPublicShare()->id; return $this->expireShare($shareId); } @@ -3449,7 +3543,7 @@ public function expireLastCreatedPublicLinkShare():ResponseInterface { * @return ResponseInterface * @throws GuzzleException */ - public function expireShare(string $shareId = null):ResponseInterface { + public function expireShare(string $shareId = null): ResponseInterface { $adminUser = $this->getAdminUsername(); if ($shareId === null) { $shareId = $this->getLastCreatedUserGroupShareId(); @@ -3473,7 +3567,7 @@ public function expireShare(string $shareId = null):ResponseInterface { * @return void * @throws GuzzleException */ - public function theAdministratorHasExpiredTheLastCreatedShare():void { + public function theAdministratorHasExpiredTheLastCreatedShare(): void { $this->expireShare(); $httpStatus = $this->getResponse()->getStatusCode(); Assert::assertSame( @@ -3499,7 +3593,7 @@ public function theAdministratorHasExpiredTheLastCreatedShare():void { * @return void * @throws GuzzleException */ - public function theAdministratorHasExpiredTheLastCreatedPublicLinkShare():void { + public function theAdministratorHasExpiredTheLastCreatedPublicLinkShare(): void { $this->expireLastCreatedPublicLinkShare(); $httpStatus = $this->getResponse()->getStatusCode(); Assert::assertSame( @@ -3525,7 +3619,7 @@ public function theAdministratorHasExpiredTheLastCreatedPublicLinkShare():void { * @return void * @throws GuzzleException */ - public function theAdministratorExpiresTheLastCreatedShare():void { + public function theAdministratorExpiresTheLastCreatedShare(): void { $this->setResponse($this->expireShare()); } @@ -3535,7 +3629,7 @@ public function theAdministratorExpiresTheLastCreatedShare():void { * @return void * @throws GuzzleException */ - public function theAdministratorExpiresTheLastCreatedPublicLinkShare():void { + public function theAdministratorExpiresTheLastCreatedPublicLinkShare(): void { $this->setResponse($this->expireLastCreatedPublicLinkShare()); } @@ -3547,7 +3641,7 @@ public function theAdministratorExpiresTheLastCreatedPublicLinkShare():void { * * @return string */ - public function replaceValuesFromTable(string $field, string $value):string { + public function replaceValuesFromTable(string $field, string $value): string { if (\substr($field, 0, 10) === "share_with") { $value = \str_replace( "REMOTE", @@ -3587,7 +3681,7 @@ public function replaceValuesFromTable(string $field, string $value):string { /** * @return array of common sharing capability settings for testing */ - protected function getCommonSharingConfigs():array { + protected function getCommonSharingConfigs(): array { return [ [ 'capabilitiesApp' => 'files_sharing', diff --git a/tests/acceptance/bootstrap/SharingNgContext.php b/tests/acceptance/bootstrap/SharingNgContext.php index 9c7e0182a01..9396a30f8b1 100644 --- a/tests/acceptance/bootstrap/SharingNgContext.php +++ b/tests/acceptance/bootstrap/SharingNgContext.php @@ -87,7 +87,8 @@ public function createLinkShare(string $user, TableNode $body): ResponseInterfac $bodyRows['quickLink'] = $bodyRows['quickLink'] ?? false; $bodyRows['displayName'] = $bodyRows['displayName'] ?? null; - $bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) ? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null; + $bodyRows['expirationDateTime'] = \array_key_exists('expirationDateTime', $bodyRows) + ? \date('Y-m-d', \strtotime($bodyRows['expirationDateTime'])) . 'T14:00:00.000Z' : null; $bodyRows['password'] = $bodyRows['password'] ?? null; $body = [ 'type' => $bodyRows['permissionsRole'], @@ -154,7 +155,12 @@ public function createDriveLinkShare(string $user, TableNode $body): ResponseInt * @return ResponseInterface * @throws GuzzleException */ - public function getPermissionsList(string $user, string $fileOrFolder, string $space, ?string $resource = ''):ResponseInterface { + public function getPermissionsList( + string $user, + string $fileOrFolder, + string $space, + ?string $resource = '' + ): ResponseInterface { $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; if ($fileOrFolder === 'folder') { @@ -184,7 +190,12 @@ public function getPermissionsList(string $user, string $fileOrFolder, string $s * @return void * @throws Exception */ - public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(string $user, string $fileOrFolder, string $resource, string $space):void { + public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI( + string $user, + string $fileOrFolder, + string $resource, + string $space + ): void { $this->featureContext->setResponse( $this->getPermissionsList($user, $fileOrFolder, $space, $resource) ); @@ -199,7 +210,7 @@ public function userGetsPermissionsListForResourceOfTheSpaceUsingTheGraphAPI(str * @return void * @throws Exception */ - public function userListsThePermissionsOfSpaceUsingTheGraphApi(string $user, string $space):void { + public function userListsThePermissionsOfSpaceUsingTheGraphApi(string $user, string $space): void { $this->featureContext->setResponse( $this->getPermissionsList($user, 'folder', $space) ); @@ -215,7 +226,11 @@ public function userListsThePermissionsOfSpaceUsingTheGraphApi(string $user, str * @return void * @throws Exception */ - public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner):void { + public function userTriesToListThePermissionsOfSpaceUsingPermissionsEndpointOfTheGraphApi( + string $user, + string $space, + string $spaceOwner + ): void { $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; $itemId = $this->spacesContext->getResourceId($spaceOwner, $space, ''); @@ -287,7 +302,12 @@ public function sendShareInvitation( if ($shareType === "user") { $shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); if ($federatedShare) { - $shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id']; + $shareeId = ( + $this->featureContext->ocmContext->getAcceptedUserByName( + $user, + $sharee + ) + )['user_id']; } } elseif ($shareType === "group") { $shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id'); @@ -333,7 +353,11 @@ public function sendShareInvitation( * @throws GuzzleException * @throws Exception */ - public function sendDriveShareInvitation(string $user, TableNode $table, bool $federatedShare = false): ResponseInterface { + public function sendDriveShareInvitation( + string $user, + TableNode $table, + bool $federatedShare = false + ): ResponseInterface { $shareeIds = []; $rows = $table->getRowsHash(); if ($rows['space'] === 'Personal' || $rows['space'] === 'Shares') { @@ -396,7 +420,11 @@ public function sendDriveShareInvitation(string $user, TableNode $table, bool $f */ public function userHasSentTheFollowingResourceShareInvitation(string $user, TableNode $table): void { $rows = $table->getRowsHash(); - Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource"); + Assert::assertArrayHasKey( + "resource", + $rows, + "'resource' should be provided in the data-table while sharing a resource" + ); $response = $this->sendShareInvitation($user, $rows); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -411,9 +439,16 @@ public function userHasSentTheFollowingResourceShareInvitation(string $user, Tab * @throws Exception * @throws GuzzleException */ - public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(string $user, TableNode $table): void { + public function userHasSentTheFollowingResourceShareInvitationToFederatedUser( + string $user, + TableNode $table + ): void { $rows = $table->getRowsHash(); - Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource"); + Assert::assertArrayHasKey( + "resource", + $rows, + "'resource' should be provided in the data-table while sharing a resource" + ); $response = $this->sendShareInvitation($user, $rows, null, true); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -430,7 +465,11 @@ public function userHasSentTheFollowingResourceShareInvitationToFederatedUser(st */ public function userHasSentTheFollowingShareShareInvitation(string $user, TableNode $table): void { $rows = $table->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while sharing a space" + ); $response = $this->sendDriveShareInvitation($user, $table); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); } @@ -448,7 +487,11 @@ public function userHasSentTheFollowingShareShareInvitation(string $user, TableN */ public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(string $user, TableNode $table): void { $rows = $table->getRowsHash(); - Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource"); + Assert::assertArrayHasKey( + "resource", + $rows, + "'resource' should be provided in the data-table while sharing a resource" + ); $this->featureContext->setResponse( $this->sendShareInvitation($user, $rows) ); @@ -464,9 +507,16 @@ public function userSendsTheFollowingResourceShareInvitationUsingTheGraphApi(str * @throws Exception * @throws GuzzleException */ - public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi(string $user, TableNode $table): void { + public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsingTheGraphApi( + string $user, + TableNode $table + ): void { $rows = $table->getRowsHash(); - Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource"); + Assert::assertArrayHasKey( + "resource", + $rows, + "'resource' should be provided in the data-table while sharing a resource" + ); $this->featureContext->setResponse( $this->sendShareInvitation($user, $rows, null, true) ); @@ -482,9 +532,16 @@ public function userSendsTheFollowingResourceShareInvitationToFederatedUserUsing * @throws Exception * @throws GuzzleException */ - public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void { + public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpointOfTheGraphApi( + string $user, + TableNode $table + ): void { $rows = $table->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while sharing a space" + ); $this->featureContext->setResponse( $this->sendShareInvitation($user, $rows) ); @@ -500,9 +557,16 @@ public function userSendsTheFollowingSpaceShareInvitationUsingPermissionsEndpoin * @throws Exception * @throws GuzzleException */ - public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $table): void { + public function userSendsTheFollowingSpaceShareInvitationToFederatedUserUsingPermissionsEndpointOfTheGraphApi( + string $user, + TableNode $table + ): void { $rows = $table->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while sharing a space" + ); $this->featureContext->setResponse( $this->sendShareInvitation($user, $rows, null, true) ); @@ -555,7 +619,12 @@ public function userUpdatesTheLastShareWithFollowingPropertiesUsingGraphApi($use * * @return void */ - public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi(string $user, string $shareType, string $sharee, TableNode $table) { + public function userUpdatesTheSpaceShareForUserOrGroupWithFollowingUsingGraphApi( + string $user, + string $shareType, + string $sharee, + TableNode $table + ) { $permissionID = ""; if ($shareType === "user") { $permissionID = "u:" . $this->featureContext->getAttributeOfCreatedUser($sharee, 'id'); @@ -600,7 +669,8 @@ public function updateResourceShare(string $user, TableNode $body, string $perm } if (\array_key_exists('expirationDateTime', $bodyRows)) { - $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime']; + $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) + ? null : $bodyRows['expirationDateTime']; } return GraphHelper::updateShare( @@ -626,7 +696,11 @@ public function updateResourceShare(string $user, TableNode $body, string $perm * @throws JsonException * @throws GuzzleException */ - public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(string $user, string $fileId, TableNode $table): void { + public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi( + string $user, + string $fileId, + TableNode $table + ): void { $rows = $table->getRowsHash(); $this->featureContext->setResponse( $this->sendShareInvitation($user, $rows, $fileId) @@ -642,7 +716,7 @@ public function userSendsTheFollowingShareInvitationWithFileIdUsingTheGraphApi(s * @return void * @throws GuzzleException */ - public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body):void { + public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode $body): void { $response = $this->createLinkShare($user, $body); $this->featureContext->setResponse($response); } @@ -656,7 +730,10 @@ public function userCreatesAPublicLinkShareWithSettings(string $user, TableNode * @return void * @throws GuzzleException */ - public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void { + public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfTheGraphApi( + string $user, + TableNode $body + ): void { $this->featureContext->setResponse($this->createLinkShare($user, $body)); } @@ -671,7 +748,11 @@ public function userCreatesTheFollowingSpaceLinkShareUsingPermissionsEndpointOfT */ public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableNode $body): void { $rows = $body->getRowsHash(); - Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource"); + Assert::assertArrayHasKey( + "resource", + $rows, + "'resource' should be provided in the data-table while sharing a resource" + ); $response = $this->createLinkShare($user, $body); $this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response); $this->featureContext->shareNgAddToCreatedLinkShares($response); @@ -688,7 +769,11 @@ public function userHasCreatedTheFollowingResourceLinkShare(string $user, TableN */ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $body): void { $rows = $body->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while sharing a space" + ); $response = $this->createDriveLinkShare($user, $body); $this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while creating public share link!", $response); $this->featureContext->shareNgAddToCreatedLinkShares($response); @@ -703,7 +788,7 @@ public function userHasCreatedTheFollowingLinkShare(string $user, TableNode $bo * @return void * @throws Exception|GuzzleException */ - public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body):void { + public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body): void { $response = $this->updateLinkShare( $user, $body, @@ -721,7 +806,10 @@ public function userHasUpdatedLastPublicLinkShare(string $user, TableNode $body * @return void * @throws Exception */ - public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi(string $user, TableNode $body):void { + public function userUpdatesTheLastPublicLinkShareUsingThePermissionsEndpointOfTheGraphApi( + string $user, + TableNode $body + ): void { $this->featureContext->setResponse( $this->updateLinkShare( $user, @@ -755,7 +843,8 @@ public function updateLinkShare(string $user, TableNode $body, string $permissi } if (\array_key_exists('expirationDateTime', $bodyRows)) { - $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime']; + $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) + ? null : $bodyRows['expirationDateTime']; } if (\array_key_exists('displayName', $bodyRows)) { @@ -818,13 +907,17 @@ public function setLinkSharePassword(string $user, TableNode $body, string $per * @return void * @throws Exception */ - public function userHasSetTheFollowingPasswordForTheLastLinkShare(string $user, TableNode $body):void { + public function userHasSetTheFollowingPasswordForTheLastLinkShare(string $user, TableNode $body): void { $response = $this->setLinkSharePassword( $user, $body, $this->featureContext->shareNgGetLastCreatedLinkShareID() ); - $this->featureContext->theHTTPStatusCodeShouldBe(200, "Failed while setting public share link password!", $response); + $this->featureContext->theHTTPStatusCodeShouldBe( + 200, + "Failed while setting public share link password!", + $response + ); } /** @@ -836,7 +929,10 @@ public function userHasSetTheFollowingPasswordForTheLastLinkShare(string $user, * @return void * @throws Exception */ - public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void { + public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi( + string $user, + TableNode $body + ): void { $this->featureContext->setResponse( $this->setLinkSharePassword( $user, @@ -867,7 +963,8 @@ public function removeAccessToSpaceItem( ?string $recipient = null ): ResponseInterface { $spaceId = ($this->spacesContext->getSpaceByName($sharer, $space))["id"]; - $itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) : $this->spacesContext->getResourceId($sharer, $space, $space); + $itemId = (isset($resource)) ? $this->spacesContext->getResourceId($sharer, $space, $resource) + : $this->spacesContext->getResourceId($sharer, $space, $space); $permissionID = ""; @@ -1043,7 +1140,7 @@ public function userRemovesSharePermissionOfAResourceInLinkShareUsingGraphAPI( string $sharer, string $resource, string $space - ):void { + ): void { $this->featureContext->setResponse( $this->removeAccessToSpaceItem($sharer, 'link', $space, $resource) ); @@ -1086,7 +1183,7 @@ public function userRemovesAccessOfUserOrGroupFromSpaceUsingGraphAPI( public function userRemovesLinkFromSpaceUsingRootEndpointOfGraphAPI( string $sharer, string $space - ):void { + ): void { $this->featureContext->setResponse( $this->removeAccessToSpace($sharer, 'link', $space) ); @@ -1146,7 +1243,7 @@ public function hideOrUnhideSharedResource(string $sharee, string $shareID, bool * @return void * @throws Exception|GuzzleException */ - public function userHasDisabledSyncOfLastSharedResource(string $user):void { + public function userHasDisabledSyncOfLastSharedResource(string $user): void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); $shareSpaceId = GraphHelper::SHARES_SPACE_ID; $itemId = $shareSpaceId . '!' . $shareItemId; @@ -1158,7 +1255,11 @@ public function userHasDisabledSyncOfLastSharedResource(string $user):void { $itemId, $shareSpaceId, ); - $this->featureContext->theHTTPStatusCodeShouldBe(204, __METHOD__ . " could not disable sync of last share", $response); + $this->featureContext->theHTTPStatusCodeShouldBe( + 204, + __METHOD__ . " could not disable sync of last share", + $response + ); } /** @@ -1170,7 +1271,7 @@ public function userHasDisabledSyncOfLastSharedResource(string $user):void { * @return void * @throws Exception */ - public function userDisablesSyncOfShareUsingTheGraphApi(string $user):void { + public function userDisablesSyncOfShareUsingTheGraphApi(string $user): void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); $shareSpaceId = GraphHelper::SHARES_SPACE_ID; $itemId = $shareSpaceId . '!' . $shareItemId; @@ -1197,7 +1298,7 @@ public function userDisablesSyncOfShareUsingTheGraphApi(string $user):void { * @throws Exception * @throws GuzzleException */ - public function userHidesTheSharedResourceUsingTheGraphApi(string $user):void { + public function userHidesTheSharedResourceUsingTheGraphApi(string $user): void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); $response = $this->hideOrUnhideSharedResource($user, $shareItemId); $this->featureContext->setResponse($response); @@ -1212,7 +1313,7 @@ public function userHidesTheSharedResourceUsingTheGraphApi(string $user):void { * @throws Exception * @throws GuzzleException */ - public function userHasHiddenTheShare(string $user):void { + public function userHasHiddenTheShare(string $user): void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); $response = $this->hideOrUnhideSharedResource($user, $shareItemId); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); @@ -1227,7 +1328,7 @@ public function userHasHiddenTheShare(string $user):void { * @throws Exception * @throws GuzzleException */ - public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user):void { + public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user): void { $shareItemId = $this->featureContext->shareNgGetLastCreatedUserGroupShareID(); $response = $this->hideOrUnhideSharedResource($user, $shareItemId, false); $this->featureContext->setResponse($response); @@ -1244,7 +1345,12 @@ public function userUnhidesTheSharedResourceUsingTheGraphApi(string $user):void * @return void * @throws Exception */ - public function userEnablesSyncOfShareUsingTheGraphApi(string $user, string $share, string $offeredBy, string $space):void { + public function userEnablesSyncOfShareUsingTheGraphApi( + string $user, + string $share, + string $offeredBy, + string $space + ): void { $share = ltrim($share, '/'); $itemId = $this->spacesContext->getResourceId($offeredBy, $space, $share); $shareSpaceId = GraphHelper::SHARES_SPACE_ID; @@ -1271,7 +1377,7 @@ public function userEnablesSyncOfShareUsingTheGraphApi(string $user, string $sha * @return void * @throws Exception|GuzzleException */ - public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource):void { + public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource): void { $shareSpaceId = GraphHelper::SHARES_SPACE_ID; $itemId = ($resource === 'nonexistent') ? WebDavHelper::generateUUIDv4() : $resource; @@ -1295,7 +1401,7 @@ public function userTriesToEnableShareSyncOfResourceUsingTheGraphApi(string $use * @return void * @throws Exception|GuzzleException */ - public function userTriesToDisableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource):void { + public function userTriesToDisableShareSyncOfResourceUsingTheGraphApi(string $user, string $resource): void { $shareSpaceId = GraphHelper::SHARES_SPACE_ID; $shareID = ($resource === 'nonexistent') ? WebDavHelper::generateUUIDv4() : $resource; $itemId = $shareSpaceId . '!' . $shareID; @@ -1392,7 +1498,7 @@ public function userHasShareSynced(string $user, string $resource): void { * @return void * @throws GuzzleException */ - public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource):void { + public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string $status, string $resource): void { $this->waitAndCheckShareSyncStatus($user, $resource, $status); } @@ -1406,11 +1512,15 @@ public function userShouldHaveSyncEnabledOrDisabledForShare(string $user, string * @throws Exception * @throws GuzzleException */ - public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles(string $user, TableNode $table): void { + public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedPermissionRoles( + string $user, + TableNode $table + ): void { $listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) { Assert::fail( - "The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse + "The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" + . $listPermissionResponse ); } Assert::assertNotEmpty( @@ -1431,8 +1541,13 @@ public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedP foreach ($allowedPermissionRoles as $role) { //we should be able to send share invitation for each of the role allowed for the files/folders which are listed in permissions (allowed) $roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id); - $responseSendInvitation = $this->sendShareInvitation($user, array_merge($rows, ['permissionsRole' => $roleAllowed])); - $jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation); + $responseSendInvitation = $this->sendShareInvitation( + $user, + array_merge($rows, ['permissionsRole' => $roleAllowed]) + ); + $jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent( + $responseSendInvitation + ); $httpsStatusCode = $responseSendInvitation->getStatusCode(); if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) { // remove the share so that the same user can be share for the next allowed roles @@ -1440,7 +1555,8 @@ public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedP Assert::assertEquals(204, $removePermissionsResponse->getStatusCode()); } else { $areAllSendInvitationSuccessFullForAllowedRoles = false; - $shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail . "' with role '" . $roleAllowed . "' failed and was not allowed.\n"; + $shareInvitationRequestResult .= "\tShare invitation for " . $resourceDetail + . "' with role '" . $roleAllowed . "' failed and was not allowed.\n"; } } Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult); @@ -1457,7 +1573,7 @@ public function userShouldBeAbleToSendShareTheFollowingInvitationWithAllAllowedP * @throws GuzzleException * */ - public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space):void { + public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(string $user, string $space): void { $spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"]; $response = GraphHelper::getDrivePermissionsList( @@ -1479,7 +1595,10 @@ public function userListsThePermissionsOfDriveUsingRootEndPointOFTheGraphApi(str * @return void * @throws GuzzleException */ - public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi(string $user, TableNode $table):void { + public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi( + string $user, + TableNode $table + ): void { $response = $this->sendDriveShareInvitation($user, $table); $this->featureContext->setResponse($response); } @@ -1493,7 +1612,10 @@ public function userSendsTheFollowingShareInvitationUsingRootEndPointTheGraphApi * @return void * @throws GuzzleException */ - public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi(string $user, TableNode $table):void { + public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndPointTheGraphApi( + string $user, + TableNode $table + ): void { $response = $this->sendDriveShareInvitation($user, $table, true); $this->featureContext->setResponse($response); } @@ -1507,7 +1629,10 @@ public function userSendsTheFollowingShareInvitationToFederatedUserUsingRootEndP * @return void * @throws GuzzleException */ - public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi(string $user, TableNode $table): void { + public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfTheGraphApi( + string $user, + TableNode $table + ): void { $bodyRows = $table->getRowsHash(); $permissionID = match ($bodyRows['shareType']) { 'user' => 'u:' . $this->featureContext->getAttributeOfCreatedUser($bodyRows['sharee'], 'id'), @@ -1523,7 +1648,8 @@ public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfT } if (\array_key_exists('expirationDateTime', $bodyRows)) { - $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) ? null : $bodyRows['expirationDateTime']; + $body['expirationDateTime'] = empty($bodyRows['expirationDateTime']) + ? null : $bodyRows['expirationDateTime']; } $this->featureContext->setResponse( @@ -1548,9 +1674,16 @@ public function userUpdatesTheLastDriveShareWithTheFollowingUsingRootEndpointOfT * @return void * @throws GuzzleException */ - public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi(string $user, TableNode $body): void { + public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraphApi( + string $user, + TableNode $body + ): void { $rows = $body->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while sharing a space"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while sharing a space" + ); $response = $this->createDriveLinkShare($user, $body); $this->featureContext->setResponse($response); @@ -1565,9 +1698,16 @@ public function userCreatesTheFollowingSpaceLinkShareUsingRootEndpointOfTheGraph * @return void * @throws GuzzleException */ - public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(string $user, TableNode $body): void { + public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI( + string $user, + TableNode $body + ): void { $rows = $body->getRowsHash(); - Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while setting password in space shared link"); + Assert::assertArrayNotHasKey( + "resource", + $rows, + "'resource' should not be provided in the data-table while setting password in space shared link" + ); Assert::assertArrayHasKey("password", $rows, "'password' is missing in the data-table"); $body = [ @@ -1599,7 +1739,11 @@ public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEnd * @return void * @throws GuzzleException */ - public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void { + public function userTriesToRemoveShareLinkOfSpaceOwnedByUsingRootEndpointOfTheGraphApi( + string $user, + string $space, + string $spaceOwner + ): void { $permissionID = $this->featureContext->shareNgGetLastCreatedLinkShareID(); $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; @@ -1638,10 +1782,18 @@ public function userShouldNotHaveAnyPermissionsOnSpace(string $user, string $sha foreach ($responseBody['value'] as $value) { switch ($shareType) { case $shareType === 'link': - Assert::assertArrayNotHasKey('link', $value, $space . ' space should not have any link permissions but found ' . print_r($value, true)); + Assert::assertArrayNotHasKey( + 'link', + $value, + $space . ' space should not have any link permissions but found ' . print_r($value, true) + ); break; case $shareType === "share": - Assert::assertArrayNotHasKey('grantedToV2', $value, $space . ' space should not have any share permissions but found ' . print_r($value, true)); + Assert::assertArrayNotHasKey( + 'grantedToV2', + $value, + $space . ' space should not have any share permissions but found ' . print_r($value, true) + ); break; default: Assert::fail('Invalid share type has been specified'); @@ -1657,12 +1809,18 @@ public function userShouldNotHaveAnyPermissionsOnSpace(string $user, string $sha * * @return void * @throws GuzzleException + * @codingStandardsIgnoreStart */ - public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi(string $user, TableNode $table): void { + public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAllowedPermissionRolesUsingRootEndpointOFTheGraphApi( + // @codingStandardsIgnoreEnd + string $user, + TableNode $table + ): void { $listPermissionResponse = $this->featureContext->getJsonDecodedResponseBodyContent(); if (!isset($listPermissionResponse->{'@libre.graph.permissions.roles.allowedValues'})) { Assert::fail( - "The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" . $listPermissionResponse + "The following response does not contain '@libre.graph.permissions.roles.allowedValues' property:\n" + . $listPermissionResponse ); } Assert::assertNotEmpty( @@ -1682,8 +1840,13 @@ public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAll foreach ($allowedPermissionRoles as $role) { // we should be able to send share invitation for each of the roles allowed which are listed in permissions (allowed) $roleAllowed = GraphHelper::getPermissionNameByPermissionRoleId($role->id); - $responseSendInvitation = $this->sendDriveShareInvitation($user, new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]]))); - $jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent($responseSendInvitation); + $responseSendInvitation = $this->sendDriveShareInvitation( + $user, + new TableNode(array_merge($table->getTable(), [['permissionsRole', $roleAllowed]])) + ); + $jsonResponseSendInvitation = $this->featureContext->getJsonDecodedResponseBodyContent( + $responseSendInvitation + ); $httpsStatusCode = $responseSendInvitation->getStatusCode(); if ($httpsStatusCode === 200 && !empty($jsonResponseSendInvitation->value)) { // remove the share so that the same user can be share for the next allowed roles @@ -1691,7 +1854,8 @@ public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAll Assert::assertEquals(204, $removePermissionsResponse->getStatusCode()); } else { $areAllSendInvitationSuccessFullForAllowedRoles = false; - $shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '" . $roleAllowed . "' failed and was not allowed.\n"; + $shareInvitationRequestResult .= "\tShare invitation for " . $space . "' with role '" + . $roleAllowed . "' failed and was not allowed.\n"; } } Assert::assertTrue($areAllSendInvitationSuccessFullForAllowedRoles, $shareInvitationRequestResult); @@ -1707,7 +1871,11 @@ public function userShouldBeAbleToSendTheFollowingSpaceShareInvitationWithAllAll * @return void * @throws GuzzleException */ - public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi(string $user, string $space, string $spaceOwner): void { + public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTheGraphApi( + string $user, + string $space, + string $spaceOwner + ): void { $spaceId = ($this->spacesContext->getSpaceByName($spaceOwner, $space))["id"]; $response = GraphHelper::getDrivePermissionsList( @@ -1728,8 +1896,13 @@ public function userTriesToListThePermissionsOfSpaceOwnedByUsingRootEndpointOfTh * * @return void */ - public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi(string $user, string $space):void { - $this->featureContext->setResponse($this->removeAccessToSpaceItem($user, 'link', $space, '')); + public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGraphApi( + string $user, + string $space + ): void { + $this->featureContext->setResponse( + $this->removeAccessToSpaceItem($user, 'link', $space, '') + ); } /** @@ -1745,7 +1918,14 @@ public function userRemovesTheLastLinkShareOfSpaceUsingPermissionsEndpointOfGrap * @throws JsonException * @throws Exception */ - public function checkIfShareExists(string $share, string $sharee, string $sharer, string $space, bool $shouldExist = true, bool $federatedShare = false): void { + public function checkIfShareExists( + string $share, + string $sharee, + string $sharer, + string $space, + bool $shouldExist = true, + bool $federatedShare = false + ): void { $share = \ltrim($share, "/"); if (\strtolower($space) === "personal") { $remoteDriveAlias = "personal/" . \strtolower($sharer); @@ -1765,11 +1945,18 @@ public function checkIfShareExists(string $share, string $sharee, string $sharer $driveList = HttpRequestHelper::getJsonDecodedResponseBodyContent($response)->value; $foundShareMountpoint = false; foreach ($driveList as $drive) { - if ($drive->driveType === "mountpoint" && $drive->name === $share && $drive->root->remoteItem->driveAlias === $remoteDriveAlias) { + if ($drive->driveType === "mountpoint" + && $drive->name === $share + && $drive->root->remoteItem->driveAlias === $remoteDriveAlias + ) { $foundShareMountpoint = true; } } - Assert::assertSame($shouldExist, $foundShareMountpoint, "Share mountpoint '$share' was not found in the drives list."); + Assert::assertSame( + $shouldExist, + $foundShareMountpoint, + "Share mountpoint '$share' was not found in the drives list." + ); } // check share in shared-with-me list @@ -1793,7 +1980,11 @@ public function checkIfShareExists(string $share, string $sharee, string $sharer break; } } - Assert::assertSame($shouldExist, $foundShareInSharedWithMe, "Share '$share' was not found in the shared-with-me list"); + Assert::assertSame( + $shouldExist, + $foundShareInSharedWithMe, + "Share '$share' was not found in the shared-with-me list" + ); } /** @@ -1807,7 +1998,13 @@ public function checkIfShareExists(string $share, string $sharee, string $sharer * * @return void */ - public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void { + public function userShouldHaveShareSharedByUserFromSpace( + string $sharee, + string $shouldOrNot, + string $share, + string $sharer, + string $space + ): void { $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should"); } @@ -1822,7 +2019,13 @@ public function userShouldHaveShareSharedByUserFromSpace(string $sharee, string * * @return void */ - public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(string $sharee, string $shouldOrNot, string $share, string $sharer, string $space): void { + public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace( + string $sharee, + string $shouldOrNot, + string $share, + string $sharer, + string $space + ): void { $this->checkIfShareExists($share, $sharee, $sharer, $space, $shouldOrNot === "should", true); } @@ -1837,7 +2040,13 @@ public function userShouldOrShouldNotHaveFederatedShareSharedByUserFromSpace(str * * @return void */ - public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(string $sharer, string $space, string $sharee, string $role, TableNode $table):void { + public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole( + string $sharer, + string $space, + string $sharee, + string $role, + TableNode $table + ): void { $rows = $table->getRows(); foreach ($rows as $row) { if (isset($row[0])) { @@ -1861,7 +2070,7 @@ public function userHasSharedTheFollowingFilesFromSpaceWithUserAndRole(string $s * * @return void */ - public function theJsonResponseShouldContainTheFollowingShares(TableNode $table):void { + public function theJsonResponseShouldContainTheFollowingShares(TableNode $table): void { $responseBody = $this->featureContext->getJsonDecodedResponseBodyContent(); $resourceNames = []; diff --git a/tests/acceptance/bootstrap/SpacesContext.php b/tests/acceptance/bootstrap/SpacesContext.php index 3cc044b71c4..c5d68109887 100644 --- a/tests/acceptance/bootstrap/SpacesContext.php +++ b/tests/acceptance/bootstrap/SpacesContext.php @@ -203,7 +203,8 @@ public function getSpaceByName(string $user, string $spaceName): array { $this->$listSpacesFn($user); $spaces = $this->getAvailableSpaces(); - $tryAgain = !\array_key_exists($spaceName, $spaces) && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); + $tryAgain = !\array_key_exists($spaceName, $spaces) + && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly(); if ($tryAgain) { $retried += 1; echo "Space '$spaceName' not found for user '$user', retrying ($retried)...\n"; @@ -213,7 +214,10 @@ public function getSpaceByName(string $user, string $spaceName): array { } while ($tryAgain); Assert::assertArrayHasKey($spaceName, $spaces, "Space with name '$spaceName' for user '$user' not found"); - Assert::assertNotEmpty($spaces[$spaceName]["root"]["webDavUrl"], "WebDavUrl for space with name '$spaceName' for user '$user' not found"); + Assert::assertNotEmpty( + $spaces[$spaceName]["root"]["webDavUrl"], + "WebDavUrl for space with name '$spaceName' for user '$user' not found" + ); return $spaces[$spaceName]; } @@ -275,7 +279,12 @@ public function getSharesRemoteItemId(string $user, string $share): string { * @return ResponseInterface * @throws GuzzleException */ - public function getFileData(string $user, string $spaceName, string $fileName, bool $federatedShare = false): ResponseInterface { + public function getFileData( + string $user, + string $spaceName, + string $fileName, + bool $federatedShare = false + ): ResponseInterface { $baseUrl = $this->featureContext->getBaseUrl(); if ($federatedShare) { @@ -373,7 +382,15 @@ public function getPrivateLink(string $user, string $spaceName): string { "files", WebDavHelper::DAV_VERSION_SPACES ); - $responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->xpath("//d:response/d:propstat/d:prop/oc:privatelink")), true, 512, JSON_THROW_ON_ERROR); + $responseArray = json_decode( + json_encode( + HttpRequestHelper::getResponseXml($response, __METHOD__) + ->xpath("//d:response/d:propstat/d:prop/oc:privatelink") + ), + true, + 512, + JSON_THROW_ON_ERROR + ); Assert::assertNotEmpty($responseArray, "the PROPFIND response for $spaceName is empty"); return $responseArray[0][0]; } @@ -539,7 +556,11 @@ public function sendCreateFolderRequest( * @throws GuzzleException * @throws Exception */ - public function listAllAvailableSpacesOfUser(string $user, string $query = '', array $headers = []): ResponseInterface { + public function listAllAvailableSpacesOfUser( + string $user, + string $query = '', + array $headers = [] + ): ResponseInterface { $response = GraphHelper::getMySpaces( $this->featureContext->getBaseUrl(), $user, @@ -580,7 +601,10 @@ public function theUserListsAllHisAvailableSpacesUsingTheGraphApi(string $user, * @throws GuzzleException * @throws Exception */ - public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi(string $user, TableNode $headersTable): void { + public function theUserListsAllHisAvailableSpacesWithHeadersUsingTheGraphApi( + string $user, + TableNode $headersTable + ): void { $this->featureContext->verifyTableNodeColumns( $headersTable, ['header', 'value'] @@ -645,7 +669,11 @@ public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user, str * @return void * @throws GuzzleException */ - public function theUserLooksUpTheSingleSpaceUsingTheGraphApiByUsingItsId(string $user, string $spaceName, string $ownerUser = ''): void { + public function theUserLooksUpTheSingleSpaceUsingTheGraphApiByUsingItsId( + string $user, + string $spaceName, + string $ownerUser = '' + ): void { $space = $this->getSpaceByName(($ownerUser !== "") ? $ownerUser : $user, $spaceName); Assert::assertIsArray($space); Assert::assertNotEmpty($space["id"]); @@ -777,7 +805,12 @@ public function theUserListsTheContentOfAPersonalSpaceRootUsingTheWebDAvApi( * @return void * @throws GuzzleException */ - public function userSendsPatchRequestToTheSpaceOfUserWithData(string $user, string $spaceName, string $owner, string $data): void { + public function userSendsPatchRequestToTheSpaceOfUserWithData( + string $user, + string $spaceName, + string $owner, + string $data + ): void { $space = $this->getSpaceByName($owner, $spaceName); Assert::assertIsArray($space); Assert::assertNotEmpty($spaceId = $space["id"]); @@ -835,7 +868,14 @@ public function userTheSpaceShouldContainEntries( ): void { $space = $this->getSpaceByName($user, $spaceName); $this->featureContext->setResponse($this->propfindSpace($user, $spaceName)); - $this->featureContext->propfindResultShouldContainEntries($shouldOrNot, $expectedFiles, $user, 'PROPFIND', '', $space['id']); + $this->featureContext->propfindResultShouldContainEntries( + $shouldOrNot, + $expectedFiles, + $user, + 'PROPFIND', + '', + $space['id'] + ); } /** @@ -910,7 +950,12 @@ public function forUserTheContentOfFileOfFederatedShareShouldBe( string $share, string $fileContent ): void { - $actualFileContent = $this->getFileData($user, $share, $file, true)->getBody()->getContents(); + $actualFileContent = $this->getFileData( + $user, + $share, + $file, + true + )->getBody()->getContents(); Assert::assertEquals($fileContent, $actualFileContent, "File content did not match"); } @@ -1010,7 +1055,10 @@ public function checkPermissionsInResponse( "Expected response status code should be 200", $response ); - Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), "No space with name $spaceName found"); + Assert::assertIsArray( + $spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), + "No space with name $spaceName found" + ); $permissions = $spaceAsArray["root"]["permissions"]; $userId = $this->featureContext->getUserIdByUserName($grantedUser); @@ -1036,7 +1084,10 @@ public function checkPermissionsInResponse( public function jsonRespondedShouldNotContain( string $spaceName ): void { - Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName), "space $spaceName should not be available for a user"); + Assert::assertEmpty( + $this->getSpaceByNameFromResponse($spaceName), + "space $spaceName should not be available for a user" + ); } /** @@ -1061,9 +1112,15 @@ public function userShouldNotHaveSpace( $response ); if (\trim($shouldOrNot) === "not") { - Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName, $response), "space $spaceName should not be available for a user"); + Assert::assertEmpty( + $this->getSpaceByNameFromResponse($spaceName, $response), + "space $spaceName should not be available for a user" + ); } else { - Assert::assertNotEmpty($this->getSpaceByNameFromResponse($spaceName, $response), "space '$spaceName' should be available for a user '$user' but not found"); + Assert::assertNotEmpty( + $this->getSpaceByNameFromResponse($spaceName, $response), + "space '$spaceName' should be available for a user '$user' but not found" + ); } } @@ -1384,7 +1441,12 @@ public function theUserUploadsALocalFileToSpace( * @throws GuzzleException * @throws Exception */ - public function userHasUploadedAFileToInSpaceUsingTheWebdavApi(string $user, string $source, string $destination, string $spaceName): void { + public function userHasUploadedAFileToInSpaceUsingTheWebdavApi( + string $user, + string $source, + string $destination, + string $spaceName + ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); $response = $this->featureContext->uploadFile($user, $source, $destination, $spaceId); $this->featureContext->theHTTPStatusCodeShouldBe( @@ -1415,7 +1477,12 @@ public function theUserUploadsAFileToAnotherOwnerSpace( string $destination ): void { $spaceId = $this->getSpaceIdByName($ownerUser, $spaceName); - $response = $this->featureContext->uploadFileWithContent($user, $content, $destination, $spaceId); + $response = $this->featureContext->uploadFileWithContent( + $user, + $content, + $destination, + $spaceId + ); $this->featureContext->setResponse($response); } @@ -1475,7 +1542,9 @@ public function updateSpaceName( string $owner = '' ): void { $bodyData = ["Name" => $newName]; - $this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner)); + $this->featureContext->setResponse( + $this->updateSpace($user, $spaceName, $bodyData, $owner) + ); } /** @@ -1498,7 +1567,9 @@ public function updateSpaceDescription( string $owner = '' ): void { $bodyData = ["description" => $newDescription]; - $this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner)); + $this->featureContext->setResponse( + $this->updateSpace($user, $spaceName, $bodyData, $owner) + ); } /** @@ -1546,7 +1617,9 @@ public function updateSpaceQuota( string $owner = '' ): void { $bodyData = ["quota" => ["total" => $newQuota]]; - $this->featureContext->setResponse($this->updateSpace($user, $spaceName, $bodyData, $owner)); + $this->featureContext->setResponse( + $this->updateSpace($user, $spaceName, $bodyData, $owner) + ); } /** @@ -1757,7 +1830,7 @@ public function userCopiesFileWithinSpaceUsingTheWebDAVAPI( string $fileSource, string $fileDestination, string $spaceName - ):void { + ): void { $space = $this->getSpaceByName($user, $spaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( $user, @@ -1787,7 +1860,7 @@ public function moveFileWithinSpace( string $fileSource, string $fileDestination, string $spaceName - ):ResponseInterface { + ): ResponseInterface { $space = $this->getSpaceByName($user, $spaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( $user, @@ -1820,8 +1893,15 @@ public function userMovesFileWithinSpaceUsingTheWebDAVAPI( string $fileSource, string $fileDestination, string $spaceName - ):void { - $this->featureContext->setResponse($this->moveFileWithinSpace($user, $fileSource, $fileDestination, $spaceName)); + ): void { + $this->featureContext->setResponse( + $this->moveFileWithinSpace( + $user, + $fileSource, + $fileDestination, + $spaceName + ) + ); $this->featureContext->pushToLastHttpStatusCodesArray(); } @@ -1841,7 +1921,7 @@ public function userHasMovedFileWithinSpaceUsingTheWebDAVAPI( string $fileSource, string $fileDestination, string $spaceName - ):void { + ): void { $response = $this->moveFileWithinSpace( $user, $fileSource, @@ -1899,9 +1979,13 @@ public function userCopiesFileFromAndToSpaceBetweenSpaces( string $fileDestination, string $toSpaceName, TableNode $table = null - ):void { + ): void { $space = $this->getSpaceByName($user, $fromSpaceName); - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $toSpaceName + ); if ($table !== null) { $this->featureContext->verifyTableNodeColumns( @@ -1941,9 +2025,13 @@ public function userOverwritesFileFromAndToSpaceBetweenSpaces( string $fileDestination, string $toSpaceName, string $action - ):void { + ): void { $space = $this->getSpaceByName($user, $fromSpaceName); - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $toSpaceName + ); $headers['Overwrite'] = 'T'; $encodedName = \rawurlencode(ltrim($fileSource, "/")); @@ -1974,8 +2062,12 @@ public function userShouldNotBeAbleToDownloadFileInsideSpace( string $user, string $fileName, string $spaceName - ):void { - $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user)); + ): void { + $response = $this->featureContext->downloadFileAsUserUsingPassword( + $user, + $fileName, + $this->featureContext->getPasswordForUser($user) + ); Assert::assertGreaterThanOrEqual( 400, $response->getStatusCode(), @@ -2009,9 +2101,13 @@ public function userMovesFileFromAndToSpaceBetweenSpaces( string $fromSpaceName, string $fileDestination, string $toSpaceName - ):void { + ): void { $space = $this->getSpaceByName($user, $fromSpaceName); - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $toSpaceName + ); $encodedName = \rawurlencode(ltrim($fileSource, "/")); $baseUrl = $this->featureContext->getBaseUrl(); @@ -2033,7 +2129,12 @@ public function userMovesFileFromAndToSpaceBetweenSpaces( * @return string * @throws GuzzleException */ - public function destinationHeaderValueWithSpaceName(string $user, string $fileDestination, string $spaceName, string $endPath = null):string { + public function destinationHeaderValueWithSpaceName( + string $user, + string $fileDestination, + string $spaceName, + string $endPath = null + ): string { $space = $this->getSpaceByName($user, $spaceName); $fileDestination = $this->escapePath(\ltrim($fileDestination, "/")); $baseUrl = $this->featureContext->getBaseUrl(); @@ -2075,7 +2176,14 @@ public function copyFilesAndFoldersRequest(string $user, string $fullUrl, array * @throws GuzzleException * @return void */ - public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace(string $user, string $actionType, string $fileId, string $destinationFile, string $destinationFolder, string $toSpaceName): void { + public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace( + string $user, + string $actionType, + string $fileId, + string $destinationFile, + string $destinationFolder, + string $toSpaceName + ): void { $destinationFile = \trim($destinationFile, "/"); $destinationFolder = \trim($destinationFolder, "/"); $fileDestination = $destinationFolder . '/' . $this->escapePath($destinationFile); @@ -2086,13 +2194,22 @@ public function userCopiesOrMovesFileWithIdAsIntoFolderInsideSpace(string $user, $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; } else { - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName, $fileId); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $toSpaceName, + $fileId + ); } $fullUrl = "$baseUrl/$sourceDavPath/$fileId"; if ($actionType === 'copies') { - $this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); + $this->featureContext->setResponse( + $this->copyFilesAndFoldersRequest($user, $fullUrl, $headers) + ); } else { - $this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers)); + $this->featureContext->setResponse( + $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers) + ); } } @@ -2124,7 +2241,12 @@ public function userRenamesFileWithIdToInsideSpace( $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; } else { - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $spaceName, + $fileId + ); } $fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $this->featureContext->setResponse($this->moveFilesAndFoldersRequest($user, $fullUrl, $headers)); @@ -2163,7 +2285,12 @@ public function userHasCopiedOrMovedFileInsideSpaceUsingFileId( $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; } else { - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $spaceName, + $fileId + ); } $fullUrl = "$baseUrl/$sourceDavPath/$fileId"; if ($actionType === 'copied') { @@ -2206,7 +2333,12 @@ public function userHasRenamedFileInsideSpaceUsingFileId( $davPath = WebDavHelper::getDavPath($this->featureContext->getDavPathVersion()); $headers['Destination'] = "$baseUrl/$davPath/$sharesPath"; } else { - $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $spaceName, $fileId); + $headers['Destination'] = $this->destinationHeaderValueWithSpaceName( + $user, + $fileDestination, + $spaceName, + $fileId + ); } $fullUrl = "$baseUrl/$sourceDavPath/$fileId"; $response = $this->moveFilesAndFoldersRequest($user, $fullUrl, $headers); @@ -2279,7 +2411,13 @@ public function userHasUploadedFile( $response = $this->listAllAvailableSpacesOfUser($user); $this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response); $spaceId = $this->getSpaceIdByName($user, $spaceName); - $response = $this->featureContext->uploadFileWithContent($user, $fileContent, $destination, $spaceId, true); + $response = $this->featureContext->uploadFileWithContent( + $user, + $fileContent, + $destination, + $spaceId, + true + ); $this->featureContext->theHTTPStatusCodeShouldBe(['201', '204'], "", $response); return $response->getHeader('oc-fileid'); } @@ -2353,7 +2491,12 @@ public function shareSpace(string $user, string $spaceName, array $rows): Respon * @return void * @throws GuzzleException */ - public function userExpiresTheShareOfSpaceForUser(string $user, string $shareType, string $spaceName, string $memberUser) { + public function userExpiresTheShareOfSpaceForUser( + string $user, + string $shareType, + string $spaceName, + string $memberUser + ) { $dateTime = new DateTime('yesterday'); $rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP'); $rows['shareWith'] = $memberUser; @@ -2472,10 +2615,12 @@ public function changeShareResourceWithSettings( * @throws GuzzleException * @throws JsonException */ - public function updateSharedResource(string $user, array $rows):ResponseInterface { - $shareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : $this->featureContext->getLastCreatedUserGroupShareId(); + public function updateSharedResource(string $user, array $rows): ResponseInterface { + $shareId = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() + : $this->featureContext->getLastCreatedUserGroupShareId(); $fullUrl = $this->featureContext->getBaseUrl() . $this->ocsApiUrl . '/' . $shareId; - return HttpRequestHelper::sendRequest( + return HttpRequestHelper::sendRequest( $fullUrl, $this->featureContext->getStepLineRef(), "PUT", @@ -2496,7 +2641,11 @@ public function updateSharedResource(string $user, array $rows):ResponseInterfac * @return void * @throws GuzzleException|JsonException */ - public function userExpiresTheLastShareOfResourceInsideOfTheSpace(string $user, string $resource, string $spaceName): void { + public function userExpiresTheLastShareOfResourceInsideOfTheSpace( + string $user, + string $resource, + string $spaceName + ): void { $dateTime = new DateTime('yesterday'); $rows['expireDate'] = $dateTime->format('Y-m-d\\TH:i:sP'); if ($this->featureContext->isUsingSharingNG()) { @@ -2541,7 +2690,8 @@ public function createPublicLinkToEntityInsideOfSpaceRequest( $rows["path"] = \array_key_exists("path", $rows) ? $rows["path"] : null; $rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3; $rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null; - $rows['password'] = \array_key_exists('password', $rows) ? $this->featureContext->getActualPassword($rows['password']) : null; + $rows['password'] = \array_key_exists('password', $rows) + ? $this->featureContext->getActualPassword($rows['password']) : null; $rows["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null; $rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null; @@ -2683,7 +2833,8 @@ public function sendUnshareSpaceRequest( string $recipient ): ResponseInterface { $space = $this->getSpaceByName($user, $spaceName); - $fullUrl = $this->featureContext->getBaseUrl() . $this->ocsApiUrl . "/" . $space['id'] . "?shareWith=" . $recipient; + $fullUrl = $this->featureContext->getBaseUrl() + . $this->ocsApiUrl . "/" . $space['id'] . "?shareWith=" . $recipient; return HttpRequestHelper::delete( $fullUrl, @@ -2773,7 +2924,7 @@ public function userRemovesFileOrFolderFromSpace( public function userHasDeletedASpaceOwnedByUser( string $user, string $spaceName - ):void { + ): void { $response = $this->deleteSpace($user, $spaceName); $this->featureContext->theHTTPStatusCodeShouldBe( 204, @@ -2996,7 +3147,11 @@ public function listAllDeletedFilesFromTrash( ): ResponseInterface { $space = $this->getSpaceByName($user, $spaceName); $baseUrl = $this->featureContext->getBaseUrl(); - $davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin"); + $davPath = WebDavHelper::getDavPath( + WebDavHelper::DAV_VERSION_SPACES, + $space["id"], + "trash-bin" + ); $fullUrl = "$baseUrl/$davPath"; return HttpRequestHelper::sendRequest( $fullUrl, @@ -3041,10 +3196,20 @@ public function adminListAllDeletedFilesInTrash( // get space by admin user $space = $this->getSpaceByName($this->featureContext->getAdminUserName(), $spaceName); $baseUrl = $this->featureContext->getBaseUrl(); - $davPath = WebDavHelper::getDavPath(WebDavHelper::DAV_VERSION_SPACES, $space["id"], "trash-bin"); + $davPath = WebDavHelper::getDavPath( + WebDavHelper::DAV_VERSION_SPACES, + $space["id"], + "trash-bin" + ); $fullUrl = "$baseUrl/$davPath"; $this->featureContext->setResponse( - HttpRequestHelper::sendRequest($fullUrl, $this->featureContext->getStepLineRef(), 'PROPFIND', $user, $this->featureContext->getPasswordForUser($user)) + HttpRequestHelper::sendRequest( + $fullUrl, + $this->featureContext->getStepLineRef(), + 'PROPFIND', + $user, + $this->featureContext->getPasswordForUser($user) + ) ); } @@ -3144,7 +3309,9 @@ public function userRestoresSpaceObjectsFromTrashRequest( } if ($pathToDeletedObject === "") { - throw new Exception(__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'"); + throw new Exception( + __METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'" + ); } $baseUrl = $this->featureContext->getBaseUrl(); @@ -3193,7 +3360,9 @@ public function userDeletesObjectsFromTrashRequest( } if ($pathToDeletedObject === "") { - throw new Exception(__METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'"); + throw new Exception( + __METHOD__ . " Object '$object' was not found in the trashbin of space '$spaceName' by user '$user'" + ); } $fullUrl = $this->featureContext->getBaseUrl() . $pathToDeletedObject; @@ -3272,7 +3441,13 @@ public function downloadFile( string $spaceName ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName, $this->featureContext->getPasswordForUser($user), [], $spaceId); + $response = $this->featureContext->downloadFileAsUserUsingPassword( + $user, + $fileName, + $this->featureContext->getPasswordForUser($user), + [], + $spaceId + ); $this->featureContext->setResponse($response); } @@ -3292,7 +3467,9 @@ public function userRequestsTheChecksumViaPropfindInSpace( string $spaceName ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $this->featureContext->setResponse($this->checksumContext->propfindResourceChecksum($user, $path, $spaceId)); + $this->featureContext->setResponse( + $this->checksumContext->propfindResourceChecksum($user, $path, $spaceId) + ); } /** @@ -3316,7 +3493,14 @@ public function userUploadsFileWithChecksumWithContentInSpace( ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); $this->featureContext->setResponse( - $this->featureContext->uploadFileWithChecksumAndContent($user, $checksum, $content, $destination, false, $spaceId) + $this->featureContext->uploadFileWithChecksumAndContent( + $user, + $checksum, + $content, + $destination, + false, + $spaceId + ) ); } @@ -3339,7 +3523,9 @@ public function downloadVersionOfTheFile( string $spaceName ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $this->featureContext->setResponse($this->filesVersionsContext->downloadVersion($user, $fileName, $index, $spaceId)); + $this->featureContext->setResponse( + $this->filesVersionsContext->downloadVersion($user, $fileName, $index, $spaceId) + ); } /** @@ -3352,7 +3538,7 @@ public function downloadVersionOfTheFile( * @return void * @throws Exception */ - public function userTriesToDownloadFileVersions(string $user, string $file, string $spaceName):void { + public function userTriesToDownloadFileVersions(string $user, string $file, string $spaceName): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); $this->featureContext->setResponse( $this->filesVersionsContext->getFileVersions($user, $file, null, $spaceId) @@ -3386,7 +3572,12 @@ public function userGetsEtagOfElementInASpace(string $user, string $space, strin * @return void * @throws GuzzleException */ - public function storeEtagOfElementInSpaceForUser(string $user, string $space, string $path, ?string $storePath = ""): void { + public function storeEtagOfElementInSpaceForUser( + string $user, + string $space, + string $path, + ?string $storePath = "" + ): void { if ($storePath === "") { $storePath = $path; } @@ -3451,11 +3642,13 @@ public function theseEtagsShouldShouldNotHaveChanged(string $action, TableNode $ $storedEtag = $this->getStoredEtagForPathInSpaceOfAUser($user, $space, $path); if ($action === 'should' && $etag === $storedEtag) { $changedEtagCount++; - $changedEtagMessage .= "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not."; + $changedEtagMessage .= + "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not."; } if ($action === 'should not' && $etag !== $storedEtag) { $changedEtagCount++; - $changedEtagMessage .= "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not."; + $changedEtagMessage .= + "\nExpected etag of element '$path' for user '$user' in space '$space' to change, but it did not."; } } @@ -3472,7 +3665,7 @@ public function theseEtagsShouldShouldNotHaveChanged(string $action, TableNode $ * @return void * @throws GuzzleException | Exception */ - public function userHasStoredEtagOfElementFromSpace(string $user, string $path, string $space):void { + public function userHasStoredEtagOfElementFromSpace(string $user, string $path, string $space): void { $user = $this->featureContext->getActualUsername($user); $this->storeEtagOfElementInSpaceForUser( $user, @@ -3495,7 +3688,12 @@ public function userHasStoredEtagOfElementFromSpace(string $user, string $path, * @return void * @throws Exception | GuzzleException */ - public function userHasStoredEtagOfElementOnPathFromSpace(string $user, string $path, string $storePath, string $space):void { + public function userHasStoredEtagOfElementOnPathFromSpace( + string $user, + string $path, + string $storePath, + string $space + ): void { $user = $this->featureContext->getActualUsername($user); $this->storeEtagOfElementInSpaceForUser( $user, @@ -3503,7 +3701,9 @@ public function userHasStoredEtagOfElementOnPathFromSpace(string $user, string $ $path, $storePath ); - if ($this->storedEtags[$user][$space][$storePath] === "" || $this->storedEtags[$user][$space][$storePath] === null) { + if ($this->storedEtags[$user][$space][$storePath] === "" + || $this->storedEtags[$user][$space][$storePath] === null + ) { throw new Exception("Expected stored etag to be some string but found null!"); } } @@ -3526,7 +3726,8 @@ public function sendShareSpaceViaLinkRequest( $rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3; $rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null; - $rows['password'] = \array_key_exists('password', $rows) ? $this->featureContext->getActualPassword($rows['password']) : null; + $rows['password'] = \array_key_exists('password', $rows) + ? $this->featureContext->getActualPassword($rows['password']) : null; $rows["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null; $rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null; @@ -3549,7 +3750,9 @@ public function sendShareSpaceViaLinkRequest( $this->featureContext->getStepLineRef() ); - $this->featureContext->addToCreatedPublicShares(HttpRequestHelper::getResponseXml($response, __METHOD__)->data); + $this->featureContext->addToCreatedPublicShares( + HttpRequestHelper::getResponseXml($response, __METHOD__)->data + ); return $response; } @@ -3639,16 +3842,25 @@ public function forUserSpaceShouldContainLinks( ); $should = ($shouldOrNot !== "not"); - $responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->data), true, 512, JSON_THROW_ON_ERROR); + $responseArray = json_decode( + json_encode(HttpRequestHelper::getResponseXml($response, __METHOD__)->data), + true, + 512, + JSON_THROW_ON_ERROR + ); if ($should) { Assert::assertNotEmpty($responseArray, __METHOD__ . ' Response should contain a link, but it is empty'); foreach ($responseArray as $element) { if ($shareType === 'public link') { - $expectedLinkId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareID() : (string) $this->featureContext->getLastCreatedPublicShare()->id; + $expectedLinkId = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareID() : + (string) $this->featureContext->getLastCreatedPublicShare()->id; Assert::assertEquals($element["id"], $expectedLinkId, "link IDs are different"); } else { - $expectedShareId = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() : (string)$this->featureContext->getLastCreatedUserGroupShareId(); + $expectedShareId = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedUserGroupShareID() + : (string)$this->featureContext->getLastCreatedUserGroupShareId(); Assert::assertEquals($element["id"], $expectedShareId, "share IDs are different"); } } @@ -3674,9 +3886,14 @@ public function userGetsTheFollowingPropertiesOfFileInsideSpaceUsingTheWebdavApi string $resourceName, string $spaceName, TableNode $propertiesTable - ):void { + ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable); + $response = $this->webDavPropertiesContext->getPropertiesOfFolder( + $user, + $resourceName, + $spaceId, + $propertiesTable + ); $this->featureContext->setResponse($response); } @@ -3697,12 +3914,17 @@ public function userGetsTheFollowingExtractedPropertiesOfFileInsideSpaceUsingThe string $resourceName, string $spaceName, TableNode $propertiesTable - ):void { + ): void { // NOTE: extracting properties occurs asynchronously // short wait is necessary before getting those properties sleep(2); $spaceId = $this->getSpaceIdByName($user, $spaceName); - $response = $this->webDavPropertiesContext->getPropertiesOfFolder($user, $resourceName, $spaceId, $propertiesTable); + $response = $this->webDavPropertiesContext->getPropertiesOfFolder( + $user, + $resourceName, + $spaceId, + $propertiesTable + ); $this->featureContext->setResponse($response); } @@ -3725,9 +3947,16 @@ public function userGetsTheFollowingPropertiesOfFileInsideSpaceWithValueUsingThe string $spaceName, string $property, string $value - ):void { + ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $this->webDavPropertiesContext->checkPropertyOfAFolder($user, $resourceName, $property, $value, null, $spaceId); + $this->webDavPropertiesContext->checkPropertyOfAFolder( + $user, + $resourceName, + $property, + $value, + null, + $spaceId + ); } /** @@ -3740,9 +3969,19 @@ public function userGetsTheFollowingPropertiesOfFileInsideSpaceWithValueUsingThe * * @return void */ - public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited(string $user, string $path, string $spaceName, string $shouldOrNot):void { + public function asUserFileOrFolderInsideSpaceShouldOrNotBeFavorited( + string $user, + string $path, + string $spaceName, + string $shouldOrNot + ): void { $spaceId = $this->getSpaceIdByName($user, $spaceName); - $this->favoritesContext->asUserFileOrFolderShouldBeFavorited($user, $path, ($shouldOrNot === 'should') ? 1 : 0, $spaceId); + $this->favoritesContext->asUserFileOrFolderShouldBeFavorited( + $user, + $path, + ($shouldOrNot === 'should') ? 1 : 0, + $spaceId + ); } /** @@ -3789,7 +4028,12 @@ public function userHasStoredIdOfPathOfTheSpace(string $user, string $path, stri * @throws GuzzleException * @throws JsonException */ - public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user, string $fileOrFolder, string $path, string $spaceName): void { + public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId( + string $user, + string $fileOrFolder, + string $path, + string $spaceName + ): void { $this->getSpaceIdByName($user, $spaceName); $user = $this->featureContext->getActualUsername($user); $currentFileID = $this->featureContext->getFileIdForPath($user, $path); @@ -3798,7 +4042,8 @@ public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user $currentFileID, $storedFileID, __METHOD__ - . " User '$user' $fileOrFolder '$path' does not have the previously stored id '$storedFileID', but has '$currentFileID'." + . " User '$user' $fileOrFolder '$path' does not have the previously stored id '" + . $storedFileID . "', but has '$currentFileID'." ); } @@ -3813,7 +4058,14 @@ public function userFolderOfTheSpaceShouldHaveThePreviouslyStoredId(string $user */ public function searchResultShouldContainSpace(string $user, string $spaceName): void { // get a response after a Report request (called in the core) - $responseArray = json_decode(json_encode(HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath("//d:response/d:href")), true, 512, JSON_THROW_ON_ERROR); + $responseArray = json_decode( + json_encode( + HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath("//d:response/d:href") + ), + true, + 512, + JSON_THROW_ON_ERROR + ); Assert::assertNotEmpty($responseArray, "search result is empty"); // for mountpoint, id looks a little different than for project space @@ -3857,7 +4109,11 @@ public function searchResultShouldContainSpace(string $user, string $spaceName): * * @throws GuzzleException */ - public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(string $user, string $spaceName, ?string $folderDepth = "1"): void { + public function userSendsPropfindRequestToSpaceUsingTheWebdavApi( + string $user, + string $spaceName, + ?string $folderDepth = "1" + ): void { $this->featureContext->setResponse( $this->sendPropfindRequestToSpace($user, $spaceName, "", null, $folderDepth) ); @@ -3878,7 +4134,12 @@ public function userSendsPropfindRequestToSpaceUsingTheWebdavApi(string $user, s * * @throws GuzzleException */ - public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi(string $user, string $spaceName, string $resource, ?string $folderDepth = "1"): void { + public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingTheWebdavApi( + string $user, + string $spaceName, + string $resource, + ?string $folderDepth = "1" + ): void { $response = $this->sendPropfindRequestToSpace($user, $spaceName, $resource, null, $folderDepth); $this->featureContext->setResponse($response); } @@ -3896,7 +4157,11 @@ public function userSendsPropfindRequestFromTheSpaceToTheResourceWithDepthUsingT * * @throws GuzzleException */ - public function userSendsPropfindRequestToSpaceWithHeaders(string $user, string $spaceName, TableNode $headersTable): void { + public function userSendsPropfindRequestToSpaceWithHeaders( + string $user, + string $spaceName, + TableNode $headersTable + ): void { $this->featureContext->verifyTableNodeColumns( $headersTable, ['header', 'value'] @@ -3922,7 +4187,13 @@ public function userSendsPropfindRequestToSpaceWithHeaders(string $user, string * * @throws JsonException */ - public function sendPropfindRequestToSpace(string $user, string $spaceName, ?string $resource = "", ?array $headers = [], ?string $folderDepth = "1"): ResponseInterface { + public function sendPropfindRequestToSpace( + string $user, + string $spaceName, + ?string $resource = "", + ?array $headers = [], + ?string $folderDepth = "1" + ): ResponseInterface { $spaceId = $this->getSpaceIdByName($user, $spaceName); $properties = [ 'oc:id', @@ -3956,7 +4227,7 @@ public function sendPropfindRequestToSpace(string $user, string $spaceName, ?str } } - return WebDavHelper::propfind( + return WebDavHelper::propfind( $this->featureContext->getBaseUrl(), $this->featureContext->getActualUsername($user), $this->featureContext->getPasswordForUser($user), @@ -3984,7 +4255,12 @@ public function sendPropfindRequestToSpace(string $user, string $spaceName, ?str * @throws GuzzleException * @throws JsonException */ - public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair(string $user, string $type, string $resource, TableNode $table): void { + public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValuePair( + string $user, + string $type, + string $resource, + TableNode $table + ): void { $this->featureContext->verifyTableNodeColumns($table, ['key', 'value']); if ($this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES && $type === 'space') { $space = $this->getSpaceByName($user, $resource); @@ -4006,7 +4282,11 @@ public function asUsertheXMLResponseShouldContainMountpointWithTheseKeyAndValueP * * @return string */ - public function buildXpathErrorMessage(SimpleXMLElement $responseXmlObject, array $xpaths, string $message): string { + public function buildXpathErrorMessage( + SimpleXMLElement $responseXmlObject, + array $xpaths, + string $message + ): string { return "Using xpaths:\n\t- " . \join("\n\t- ", $xpaths) . "\n" . $message @@ -4022,7 +4302,11 @@ public function buildXpathErrorMessage(SimpleXMLElement $responseXmlObject, arra * @return string * @throws Exception */ - public function getXpathSiblingValue(SimpleXMLElement $responseXmlObject, string $siblingXpath, string $siblingToFind): string { + public function getXpathSiblingValue( + SimpleXMLElement $responseXmlObject, + string $siblingXpath, + string $siblingToFind + ): string { $xpaths[] = $siblingXpath . "/preceding-sibling::$siblingToFind"; $xpaths[] = $siblingXpath . "/following-sibling::$siblingToFind"; @@ -4032,7 +4316,11 @@ public function getXpathSiblingValue(SimpleXMLElement $responseXmlObject, string break; } } - $errorMessage = $this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Could not find sibling '<$siblingToFind>' element in the XML response"); + $errorMessage = $this->buildXpathErrorMessage( + $responseXmlObject, + $xpaths, + "Could not find sibling '<$siblingToFind>' element in the XML response" + ); Assert::assertNotEmpty($foundSibling, $errorMessage); return \preg_quote($foundSibling[0]->__toString(), "/"); } @@ -4067,10 +4355,15 @@ public function theXMLResponseShouldContain(string $resource, array $properties) if ($property['key'] === 'oc:name') { $xpath = "//oc:name[text()='$decodedResource']"; } elseif (\array_key_exists('oc:shareroot', $properties)) { - $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/"; - $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; - $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/preceding-sibling::/"; - $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" . $properties['oc:shareroot'] . "'/following-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" + . $properties['oc:shareroot'] . "'/preceding-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/preceding-sibling::oc:shareroot[text()='" + . $properties['oc:shareroot'] . "'/following-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" + + . $properties['oc:shareroot'] . "'/preceding-sibling::/"; + $xpaths[] = "//oc:name[text()='$resource']/following-sibling::oc:shareroot[text()='" + . $properties['oc:shareroot'] . "'/following-sibling::/"; } else { $xpaths[] = "//oc:name[text()='$decodedResource']/preceding-sibling::"; $xpaths[] = "//oc:name[text()='$decodedResource']/following-sibling::"; @@ -4097,11 +4390,19 @@ public function theXMLResponseShouldContain(string $resource, array $properties) Assert::assertCount( 1, $foundXmlItem, - $this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Found multiple elements for '<$itemToFind>' in the XML response") + $this->buildXpathErrorMessage( + $responseXmlObject, + $xpaths, + "Found multiple elements for '<$itemToFind>' in the XML response" + ) ); Assert::assertNotEmpty( $foundXmlItem, - $this->buildXpathErrorMessage($responseXmlObject, $xpaths, "Could not find '<$itemToFind>' element in the XML response") + $this->buildXpathErrorMessage( + $responseXmlObject, + $xpaths, + "Could not find '<$itemToFind>' element in the XML response" + ) ); $actualValue = $foundXmlItem[0]->__toString(); @@ -4131,15 +4432,27 @@ public function theXMLResponseShouldContain(string $resource, array $properties) switch ($itemToFind) { case "oc:fileid": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "fileid" in the response'); + Assert::assertMatchesRegularExpression( + $expectedValue, + $actualValue, + 'wrong "fileid" in the response' + ); break; case "oc:file-parent": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "file-parent" in the response'); + Assert::assertMatchesRegularExpression( + $expectedValue, + $actualValue, + 'wrong "file-parent" in the response' + ); break; case "oc:privatelink": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "privatelink" in the response'); + Assert::assertMatchesRegularExpression( + $expectedValue, + $actualValue, + 'wrong "privatelink" in the response' + ); break; case "oc:tags": // The value should be a comma-separated string of tag names. @@ -4167,7 +4480,11 @@ public function theXMLResponseShouldContain(string $resource, array $properties) break; case "oc:remote-item-id": $expectedValue = GraphHelper::jsonSchemaRegexToPureRegex($expectedValue); - Assert::assertMatchesRegularExpression($expectedValue, $actualValue, 'wrong "remote-item-id" in the response'); + Assert::assertMatchesRegularExpression( + $expectedValue, + $actualValue, + 'wrong "remote-item-id" in the response' + ); break; default: Assert::assertEquals($expectedValue, $actualValue, "wrong '$itemToFind' in the response"); @@ -4186,7 +4503,11 @@ public function theXMLResponseShouldContain(string $resource, array $properties) * @return void * @throws GuzzleException */ - public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare(string $user, string $key, string $resource): void { + public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDriveitemidOfShare( + string $user, + string $key, + string $resource + ): void { $responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__); $fileId = $responseXmlObject->xpath("//oc:name[text()='$resource']/preceding-sibling::$key")[0]->__toString(); @@ -4219,7 +4540,9 @@ public function asUserTheKeyFromPropfindResponseShouldMatchWithSharedwithmeDrive * @throws Exception */ public function publicDownloadsTheFolderFromTheLastCreatedPublicLink(string $resource) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $responseXmlObject = HttpRequestHelper::getResponseXml( $this->featureContext->listFolder( @@ -4293,14 +4616,26 @@ public function theUserShouldHaveSpaceWithRecipient( "Expected response status code should be 200", $response ); - Assert::assertIsArray($spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), "No space with name $spaceName found"); - $recipientType === 'user' ? $recipientId = $this->featureContext->getUserIdByUserName($recipient) : $recipientId = $this->featureContext->getGroupIdByGroupName($recipient); + Assert::assertIsArray( + $spaceAsArray = $this->getSpaceByNameFromResponse($spaceName, $response), + "No space with name $spaceName found" + ); + $recipientType === 'user' ? + $recipientId = $this->featureContext->getUserIdByUserName($recipient) + : $recipientId = $this->featureContext->getGroupIdByGroupName($recipient); $foundRoleInResponse = false; foreach ($spaceAsArray['root']['permissions'] as $permission) { - if (isset($permission['grantedToIdentities'][0][$recipientType]) && $permission['roles'][0] === $role && $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId) { + if (isset($permission['grantedToIdentities'][0][$recipientType]) + && $permission['roles'][0] === $role + && $permission['grantedToIdentities'][0][$recipientType]['id'] === $recipientId + ) { $foundRoleInResponse = true; if ($expirationDate !== null && isset($permission['expirationDateTime'])) { - Assert::assertEquals($expirationDate, (preg_split("/[\sT]+/", $permission['expirationDateTime']))[0], "$expirationDate is different in the response"); + Assert::assertEquals( + $expirationDate, + (preg_split("/[\sT]+/", $permission['expirationDateTime']))[0], + "$expirationDate is different in the response" + ); } break; } @@ -4320,7 +4655,7 @@ public function theUserShouldHaveSpaceWithRecipient( * * @throws GuzzleException */ - public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spaceName, string $owner = ''):void { + public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spaceName, string $owner = ''): void { $space = $this->getSpaceByName($owner ?: $user, $spaceName); $url = $this->archiverContext->getArchiverUrl('id=' . $space['id']); $this->featureContext->setResponse( @@ -4344,7 +4679,12 @@ public function userDownloadsTheSpaceUsingTheWebdavApi(string $user, string $spa * @return void * @throws GuzzleException */ - public function userHasSharedResourceInsideSpaceWithUser(string $sharer, string $path, string $space, string $sharee): void { + public function userHasSharedResourceInsideSpaceWithUser( + string $sharer, + string $path, + string $space, + string $sharee + ): void { $sharer = $this->featureContext->getActualUsername($sharer); $resource_id = $this->getResourceId($sharer, $space, $path); $response = $this->featureContext->createShare( @@ -4367,7 +4707,8 @@ public function userHasSharedResourceInsideSpaceWithUser(string $sharer, string Assert::assertContainsEquals( $responseStatusCode, $statusCodes, - "OCS status code is not any of the expected values " . \implode(",", $statusCodes) . " got " . $responseStatusCode + "OCS status code is not any of the expected values " + . \implode(",", $statusCodes) . " got " . $responseStatusCode ); } @@ -4380,7 +4721,7 @@ public function userHasSharedResourceInsideSpaceWithUser(string $sharer, string * * @return void */ - public function userGetsTheDriveItemInSpace(string $user, string $file, string $space):void { + public function userGetsTheDriveItemInSpace(string $user, string $file, string $space): void { $spaceId = ($this->getSpaceByName($user, $space))["id"]; $itemId = ''; if ($space === "Shares") { diff --git a/tests/acceptance/bootstrap/SpacesTUSContext.php b/tests/acceptance/bootstrap/SpacesTUSContext.php index 7a6ed162125..a179244d7ef 100644 --- a/tests/acceptance/bootstrap/SpacesTUSContext.php +++ b/tests/acceptance/bootstrap/SpacesTUSContext.php @@ -61,7 +61,12 @@ public function before(BeforeScenarioScope $scope): void { * @throws Exception * @throws GuzzleException */ - public function userHasUploadedFileViaTusInSpace(string $user, string $source, string $destination, string $spaceName): void { + public function userHasUploadedFileViaTusInSpace( + string $user, + string $source, + string $destination, + string $spaceName + ): void { $spaceId = $this->spacesContext->getSpaceIdByName($user, $spaceName); $this->tusContext->uploadFileUsingTus($user, $source, $destination, $spaceId); $this->featureContext->setLastUploadDeleteTime(\time()); @@ -175,7 +180,12 @@ private function uploadFileViaTus(string $user, string $content, string $resourc * @return void * @throws Exception|GuzzleException */ - public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi(string $user, string $content, string $file, string $destination): void { + public function userUploadsAFileWithContentToInsideFederatedShareViaTusUsingTheWebdavApi( + string $user, + string $content, + string $file, + string $destination + ): void { $remoteItemId = $this->spacesContext->getSharesRemoteItemId($user, $destination); $remoteItemId = \rawurlencode($remoteItemId); $tmpFile = $this->tusContext->writeDataToTempFile($content); @@ -293,8 +303,10 @@ public function userUploadsAFileToWithMtimeViaTusInsideOfTheSpaceUsingTheWebdavA * * @return void * @throws Exception|GuzzleException + * @codingStandardsIgnoreStart */ public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi( + // @codingStandardsIgnoreEnd string $user, string $checksum, string $offset, @@ -317,8 +329,10 @@ public function userHasUploadedFileWithChecksumToTheLastCreatedTusLocationWithOf * * @return void * @throws Exception|GuzzleException + * @codingStandardsIgnoreStart */ public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffsetAndContentViaTusInsideOfTheSpaceUsingTheWebdavApi( + // @codingStandardsIgnoreEnd string $user, string $checksum, string $offset, @@ -341,8 +355,10 @@ public function userUploadsFileWithChecksumToTheLastCreatedTusLocationWithOffset * * @return void * @throws Exception|GuzzleException + * @codingStandardsIgnoreStart */ public function userSendsAChunkToTheLastCreatedTusLocationWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApi( + // @codingStandardsIgnoreEnd string $user, string $offset, string $data, @@ -371,7 +387,14 @@ public function userSendsAChunkToTheLastCreatedTusLocationWithDataInsideOfTheSpa ): void { $rows = $headers->getRowsHash(); $resourceLocation = $this->tusContext->getLastTusResourceLocation(); - $response = $this->tusContext->uploadChunkToTUSLocation($user, $resourceLocation, $rows['Upload-Offset'], $data, $rows['Upload-Checksum'], ['Origin' => $rows['Origin']]); + $response = $this->tusContext->uploadChunkToTUSLocation( + $user, + $resourceLocation, + $rows['Upload-Offset'], + $data, + $rows['Upload-Checksum'], + ['Origin' => $rows['Origin']] + ); $this->featureContext->setResponse($response); } @@ -387,8 +410,10 @@ public function userSendsAChunkToTheLastCreatedTusLocationWithDataInsideOfTheSpa * * @return void * @throws GuzzleException + * @codingStandardsIgnoreStart */ public function userOverwritesRecentlySharedFileWithOffsetAndDataWithChecksumViaTusInsideOfTheSpaceUsingTheWebdavApiWithTheseHeaders( + // @codingStandardsIgnoreEnd string $user, string $offset, string $data, diff --git a/tests/acceptance/bootstrap/TUSContext.php b/tests/acceptance/bootstrap/TUSContext.php index 50640e76f39..4d023a0e01c 100644 --- a/tests/acceptance/bootstrap/TUSContext.php +++ b/tests/acceptance/bootstrap/TUSContext.php @@ -97,7 +97,12 @@ public function parseFilenameHash(string $uploadMetadata): string { * @throws Exception * @throws GuzzleException */ - public function createNewTUSResourceWithHeaders(string $user, TableNode $headersTable, string $content = '', ?string $spaceId = null): ResponseInterface { + public function createNewTUSResourceWithHeaders( + string $user, + TableNode $headersTable, + string $content = '', + ?string $spaceId = null + ): ResponseInterface { $this->featureContext->verifyTableNodeColumnsCount($headersTable, 2); $user = $this->featureContext->getActualUsername($user); $password = $this->featureContext->getUserPassword($user); @@ -163,7 +168,7 @@ public function userHasCreatedNewTUSResourceWithHeaders(string $user, TableNode * * @return ResponseInterface */ - public function createNewTUSResource(string $user, TableNode $headers, ?string $spaceId = null):ResponseInterface { + public function createNewTUSResource(string $user, TableNode $headers, ?string $spaceId = null): ResponseInterface { $rows = $headers->getRows(); $rows[] = ['Tus-Resumable', '1.0.0']; return $this->createNewTUSResourceWithHeaders($user, new TableNode($rows), '', $spaceId); @@ -182,7 +187,14 @@ public function createNewTUSResource(string $user, TableNode $headers, ?string $ * @throws GuzzleException * @throws JsonException */ - public function uploadChunkToTUSLocation(string $user, string $resourceLocation, string $offset, string $data, string $checksum = '', ?array $extraHeaders = null): ResponseInterface { + public function uploadChunkToTUSLocation( + string $user, + string $resourceLocation, + string $offset, + string $data, + string $checksum = '', + ?array $extraHeaders = null + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $password = $this->featureContext->getUserPassword($user); $headers = [ @@ -631,7 +643,12 @@ public function userHasUploadedFileWithChecksum( * @return void * @throws Exception */ - public function userUploadsChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void { + public function userUploadsChunkFileWithChecksum( + string $user, + string $offset, + string $data, + string $checksum + ): void { $resourceLocation = $this->getLastTusResourceLocation(); $response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum); $this->featureContext->setResponse($response); @@ -648,7 +665,12 @@ public function userUploadsChunkFileWithChecksum(string $user, string $offset, s * @return void * @throws Exception */ - public function userHasUploadedChunkFileWithChecksum(string $user, string $offset, string $data, string $checksum): void { + public function userHasUploadedChunkFileWithChecksum( + string $user, + string $offset, + string $data, + string $checksum + ): void { $resourceLocation = $this->getLastTusResourceLocation(); $response = $this->uploadChunkToTUSLocation($user, $resourceLocation, $offset, $data, $checksum); $this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response); @@ -669,7 +691,13 @@ public function userHasUploadedChunkFileWithChecksum(string $user, string $offse * @throws GuzzleException * @throws Exception */ - public function userOverwritesFileWithChecksum(string $user, string $offset, string $data, string $checksum, TableNode $headers): void { + public function userOverwritesFileWithChecksum( + string $user, + string $offset, + string $data, + string $checksum, + TableNode $headers + ): void { $createResponse = $this->createNewTUSResource($user, $headers); $this->featureContext->theHTTPStatusCodeShouldBe(201, "", $createResponse); $resourceLocation = $this->getLastTusResourceLocation(); diff --git a/tests/acceptance/bootstrap/TagContext.php b/tests/acceptance/bootstrap/TagContext.php index 678f39ab412..f057a02653d 100644 --- a/tests/acceptance/bootstrap/TagContext.php +++ b/tests/acceptance/bootstrap/TagContext.php @@ -64,7 +64,13 @@ public function before(BeforeScenarioScope $scope): void { * @return ResponseInterface * @throws Exception */ - public function createTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface { + public function createTags( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): ResponseInterface { $tagNameArray = []; foreach ($table->getRows() as $value) { $tagNameArray[] = $value[0]; @@ -97,7 +103,13 @@ public function createTags(string $user, string $fileOrFolder, string $resource, * @return void * @throws Exception */ - public function theUserCreatesFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void { + public function theUserCreatesFollowingTags( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): void { $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table); $this->featureContext->setResponse($response); } @@ -114,7 +126,13 @@ public function theUserCreatesFollowingTags(string $user, string $fileOrFolder, * @return void * @throws Exception */ - public function theUserHasCreatedFollowingTags(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void { + public function theUserHasCreatedFollowingTags( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): void { $response = $this->createTags($user, $fileOrFolder, $resource, $space, $table); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); } @@ -130,7 +148,12 @@ public function theUserHasCreatedFollowingTags(string $user, string $fileOrFolde * @return void * @throws Exception */ - public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(string $user, string $filesOrFolders, string $space, TableNode $table):void { + public function userHasCreatedTheFollowingTagsForFilesOfTheSpace( + string $user, + string $filesOrFolders, + string $space, + TableNode $table + ): void { $this->featureContext->verifyTableNodeColumns($table, ["path", "tagName"]); $rows = $table->getHash(); foreach ($rows as $row) { @@ -148,7 +171,7 @@ public function userHasCreatedTheFollowingTagsForFilesOfTheSpace(string $user, s * @return void * @throws Exception */ - public function theUserGetsAllAvailableTags(string $user):void { + public function theUserGetsAllAvailableTags(string $user): void { // Note: after creating or deleting tags, in some cases tags do not appear or disappear immediately, // So wait is necessary before listing tags sleep(5); @@ -171,10 +194,12 @@ public function theUserGetsAllAvailableTags(string $user):void { * @return void * @throws Exception */ - public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table):void { + public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNode $table): void { $rows = $table->getRows(); foreach ($rows as $row) { - $responseArray = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value']; + $responseArray = $this->featureContext->getJsonDecodedResponse( + $this->featureContext->getResponse() + )['value']; if ($shouldOrNot === "not") { Assert::assertFalse( \in_array($row[0], $responseArray), @@ -201,7 +226,13 @@ public function theFollowingTagsShouldExistForUser(string $shouldOrNot, TableNod * @return ResponseInterface * @throws Exception */ - public function removeTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):ResponseInterface { + public function removeTagsFromResourceOfTheSpace( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): ResponseInterface { $tagNameArray = []; foreach ($table->getRows() as $value) { $tagNameArray[] = $value[0]; @@ -235,8 +266,20 @@ public function removeTagsFromResourceOfTheSpace(string $user, string $fileOrFol * @return void * @throws Exception */ - public function userRemovesTagsFromResourceOfTheSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void { - $response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table); + public function userRemovesTagsFromResourceOfTheSpace( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): void { + $response = $this->removeTagsFromResourceOfTheSpace( + $user, + $fileOrFolder, + $resource, + $space, + $table + ); $this->featureContext->setResponse($response); } @@ -252,7 +295,13 @@ public function userRemovesTagsFromResourceOfTheSpace(string $user, string $file * @return void * @throws Exception */ - public function userHAsRemovedTheFollowingTagsForFileOfSpace(string $user, string $fileOrFolder, string $resource, string $space, TableNode $table):void { + public function userHAsRemovedTheFollowingTagsForFileOfSpace( + string $user, + string $fileOrFolder, + string $resource, + string $space, + TableNode $table + ): void { $response = $this->removeTagsFromResourceOfTheSpace($user, $fileOrFolder, $resource, $space, $table); $this->featureContext->theHttpStatusCodeShouldBe(200, "", $response); } diff --git a/tests/acceptance/bootstrap/TrashbinContext.php b/tests/acceptance/bootstrap/TrashbinContext.php index cb657ff6415..c41b78a3c07 100644 --- a/tests/acceptance/bootstrap/TrashbinContext.php +++ b/tests/acceptance/bootstrap/TrashbinContext.php @@ -42,7 +42,7 @@ class TrashbinContext implements Context { * * @return ResponseInterface */ - public function emptyTrashbin(?string $user):ResponseInterface { + public function emptyTrashbin(?string $user): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $davPathVersion = $this->featureContext->getDavPathVersion(); return WebDavHelper::makeDavRequest( @@ -77,7 +77,7 @@ public function userEmptiesTrashbin(string $user): void { * * @return void */ - public function userHasEmptiedTrashbin(string $user):void { + public function userHasEmptiedTrashbin(string $user): void { $response = $this->emptyTrashbin($user); $this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response); } @@ -109,7 +109,9 @@ static function (SimpleXMLElement $propStat) { $name = $successPropStat->xpath('./d:prop/oc:trashbin-original-filename'); $mtime = $successPropStat->xpath('./d:prop/oc:trashbin-delete-timestamp'); $resourcetype = $successPropStat->xpath('./d:prop/d:resourcetype'); - if (\array_key_exists(0, $resourcetype) && ($resourcetype[0]->asXML() === "")) { + if (\array_key_exists(0, $resourcetype) + && ($resourcetype[0]->asXML() === "") + ) { $collection[0] = true; } else { $collection[0] = false; @@ -145,7 +147,7 @@ static function (SimpleXMLElement $propStat) { * @return array response * @throws Exception */ - public function listTopOfTrashbinFolder(?string $user, string $depth = "1"):array { + public function listTopOfTrashbinFolder(?string $user, string $depth = "1"): array { $password = $this->featureContext->getPasswordForUser($user); $davPathVersion = $this->featureContext->getDavPathVersion(); @@ -205,7 +207,7 @@ static function ($element) use ($davPathVersion, $suffixPath) { * @return array of all the items in the trashbin of the user * @throws Exception */ - public function listTrashbinFolder(?string $user, string $depth = "1"):array { + public function listTrashbinFolder(?string $user, string $depth = "1"): array { return $this->listTrashbinFolderCollection( $user, "", @@ -224,7 +226,12 @@ public function listTrashbinFolder(?string $user, string $depth = "1"):array { * @return array response * @throws Exception */ - public function listTrashbinFolderCollection(?string $user, ?string $collectionPath = "", string $depth = "1", int $level = 1):array { + public function listTrashbinFolderCollection( + ?string $user, + ?string $collectionPath = "", + string $depth = "1", + int $level = 1 + ): array { // $collectionPath should be some list of file-ids like 2147497661/2147497662 // or the empty string, which will list the whole trashbin from the top. $collectionPath = \trim($collectionPath, "/"); @@ -251,7 +258,11 @@ public function listTrashbinFolderCollection(?string $user, ?string $collectionP $response->getBody()->rewind(); $statusCode = $response->getStatusCode(); $respBody = $response->getBody()->getContents(); - Assert::assertEquals("207", $statusCode, "Expected status code to be '207' but got $statusCode \nResponse\n$respBody"); + Assert::assertEquals( + "207", + $statusCode, + "Expected status code to be '207' but got $statusCode \nResponse\n$respBody" + ); $files = $this->getTrashbinContentFromResponseXml( HttpRequestHelper::getResponseXml( @@ -331,7 +342,7 @@ static function ($element) use ($user, $trashbinRef) { * @return void * @throws Exception */ - public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth):void { + public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $user, string $depth): void { $this->listTopOfTrashbinFolder($user, $depth); } @@ -343,9 +354,11 @@ public function userGetsFilesInTheTrashbinWithDepthUsingTheWebdavApi(string $use * @return void * @throws Exception */ - public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table):void { + public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['name']); - $files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)); + $files = $this->getTrashbinContentFromResponseXml( + HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__) + ); foreach ($table->getHash() as $row) { $path = trim((string)$row['name'], "/"); @@ -365,10 +378,12 @@ public function theTrashbinDavResponseShouldNotContainTheseNodes(TableNode $tabl * @return void * @throws Exception */ - public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table):void { + public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ['name']); - $files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__)); + $files = $this->getTrashbinContentFromResponseXml( + HttpRequestHelper::getResponseXml($this->featureContext->getResponse(), __METHOD__) + ); foreach ($table->getHash() as $row) { $path = trim($row['name'], "/"); @@ -395,7 +410,11 @@ public function theTrashbinDavResponseShouldContainTheseNodes(TableNode $table): * @return ResponseInterface * @throws Exception */ - public function sendTrashbinListRequest(string $user, ?string $asUser = null, ?string $password = null): ResponseInterface { + public function sendTrashbinListRequest( + string $user, + ?string $asUser = null, + ?string $password = null + ): ResponseInterface { $asUser = $asUser ?? $user; $password = $password ?? $this->featureContext->getPasswordForUser($asUser); @@ -445,7 +464,11 @@ public function userTriesToListTheTrashbinContentForUser(string $asUser, string * @return void * @throws Exception */ - public function userTriesToListTheTrashbinContentForUserUsingPassword(string $asUser, string $user, string $password):void { + public function userTriesToListTheTrashbinContentForUserUsingPassword( + string $asUser, + string $user, + string $password + ): void { $response = $this->sendTrashbinListRequest($user, $asUser, $password); $this->featureContext->setResponse($response); } @@ -457,7 +480,7 @@ public function userTriesToListTheTrashbinContentForUserUsingPassword(string $as * * @return void */ - public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements):void { + public function theLastWebdavResponseShouldContainFollowingElements(TableNode $elements): void { $files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($response, __METHOD__)); $elementRows = $elements->getHash(); foreach ($elementRows as $expectedElement) { @@ -481,8 +504,10 @@ public function theLastWebdavResponseShouldContainFollowingElements(TableNode $e * @return void * @throws Exception */ - public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements):void { - $files = $this->getTrashbinContentFromResponseXml(HttpRequestHelper::getResponseXml($this->featureContext->getResponse())); + public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode $elements): void { + $files = $this->getTrashbinContentFromResponseXml( + HttpRequestHelper::getResponseXml($this->featureContext->getResponse()) + ); // 'user' is also allowed in the table even though it is not used anywhere // This for better readability in feature files @@ -513,7 +538,7 @@ public function theLastWebdavResponseShouldNotContainFollowingElements(TableNode * @return void * @throws Exception */ - public function userTriesToDeleteFromTrashbinOfUser(string $user, string $path, string $ofUser):void { + public function userTriesToDeleteFromTrashbinOfUser(string $user, string $path, string $ofUser): void { $response = $this->deleteItemFromTrashbin($user, $path, $ofUser); $this->featureContext->setResponse($response); } @@ -530,7 +555,12 @@ public function userTriesToDeleteFromTrashbinOfUser(string $user, string $path, * @throws JsonException * @throws Exception */ - public function userTriesToDeleteFromTrashbinOfUserUsingPassword(string $user, string $path, string $ofUser, string $password):void { + public function userTriesToDeleteFromTrashbinOfUserUsingPassword( + string $user, + string $path, + string $ofUser, + string $password + ): void { $response = $this->deleteItemFromTrashbin($user, $path, $ofUser, $password); $this->featureContext->setResponse($response); } @@ -546,7 +576,7 @@ public function userTriesToDeleteFromTrashbinOfUserUsingPassword(string $user, s * @throws JsonException * @throws Exception */ - public function userTriesToRestoreFromTrashbinOfUser(?string $asUser, ?string $path, ?string $user):void { + public function userTriesToRestoreFromTrashbinOfUser(?string $asUser, ?string $path, ?string $user): void { $user = $this->featureContext->getActualUsername($user); $asUser = $this->featureContext->getActualUsername($asUser); $response = $this->restoreElement($user, $path, null, $asUser); @@ -565,7 +595,12 @@ public function userTriesToRestoreFromTrashbinOfUser(?string $asUser, ?string $p * @throws JsonException * @throws Exception */ - public function userTriesToRestoreFromTrashbinOfUserUsingPassword(?string $asUser, ?string $path, ?string $user, ?string $password):void { + public function userTriesToRestoreFromTrashbinOfUserUsingPassword( + ?string $asUser, + ?string $path, + ?string $user, + ?string $password + ): void { $asUser = $this->featureContext->getActualUsername($asUser); $user = $this->featureContext->getActualUsername($user); $response = $this->restoreElement($user, $path, null, $asUser, $password); @@ -579,7 +614,7 @@ public function userTriesToRestoreFromTrashbinOfUserUsingPassword(?string $asUse * * @return string */ - private function convertTrashbinHref(string $href):string { + private function convertTrashbinHref(string $href): string { $trashItemHRef = \trim($href, '/'); $trashItemHRef = \strstr($trashItemHRef, '/trash-bin'); $trashItemHRef = \trim($trashItemHRef, '/'); @@ -596,7 +631,10 @@ private function convertTrashbinHref(string $href):string { * * @return void */ - public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI(string $user, string $originalPath):void { + public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAPI( + string $user, + string $originalPath + ): void { $response = $this->deleteItemFromTrashbin($user, $originalPath); $this->featureContext->setResponse($response); } @@ -609,7 +647,12 @@ public function userTriesToDeleteFileWithOriginalPathFromTrashbinUsingTrashbinAP * * @return ResponseInterface */ - public function deleteItemFromTrashbin(string $user, string $originalPath, ?string $ofUser = null, ?string $password = null): ResponseInterface { + public function deleteItemFromTrashbin( + string $user, + string $originalPath, + ?string $ofUser = null, + ?string $password = null + ): ResponseInterface { $ofUser = $ofUser ?? $user; $user = $this->featureContext->getActualUsername($user); $ofUser = $this->featureContext->getActualUsername($ofUser); @@ -656,7 +699,7 @@ public function deleteItemFromTrashbin(string $user, string $originalPath, ?stri * @return void * @throws Exception */ - public function deleteFileFromTrashbin(string $user, string $originalPath):void { + public function deleteFileFromTrashbin(string $user, string $originalPath): void { $response = $this->deleteItemFromTrashbin($user, $originalPath); $this->featureContext->setResponse($response); $this->featureContext->pushToLastStatusCodesArrays(); @@ -671,7 +714,7 @@ public function deleteFileFromTrashbin(string $user, string $originalPath):void * @return void * @throws Exception */ - public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $user, string $originalPath):void { + public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $user, string $originalPath): void { $response = $this->deleteItemFromTrashbin($user, $originalPath); $this->featureContext->theHTTPStatusCodeShouldBe(204, '', $response); } @@ -685,7 +728,7 @@ public function userHasDeletedTheFolderWithOriginalPathFromTheTrashbin(string $u * @return void * @throws Exception */ - public function deleteFollowingFilesFromTrashbin(string $user, TableNode $table):void { + public function deleteFollowingFilesFromTrashbin(string $user, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -706,7 +749,7 @@ public function deleteFollowingFilesFromTrashbin(string $user, TableNode $table) * @throws JsonException * @throws Exception */ - public function asFileOrFolderExistsInTrash(?string $user, ?string $path):void { + public function asFileOrFolderExistsInTrash(?string $user, ?string $path): void { $user = $this->featureContext->getActualUsername($user); $path = \trim($path, '/'); $sections = \explode('/', $path, 2); @@ -756,7 +799,7 @@ public function asFileOrFolderExistsInTrash(?string $user, ?string $path):void { * @return bool * @throws Exception */ - private function isInTrash(?string $user, ?string $originalPath):bool { + private function isInTrash(?string $user, ?string $originalPath): bool { $listing = $this->listTrashbinFolder($user); // we don't care if the test step writes a leading "/" or not @@ -781,7 +824,13 @@ private function isInTrash(?string $user, ?string $originalPath):bool { * @throws JsonException * @throws GuzzleException */ - private function sendUndeleteRequest(string $user, string $trashItemHRef, string $destinationPath, ?string $asUser = null, ?string $password = null):ResponseInterface { + private function sendUndeleteRequest( + string $user, + string $trashItemHRef, + string $destinationPath, + ?string $asUser = null, + ?string $password = null + ): ResponseInterface { $asUser = $asUser ?? $user; $password = $password ?? $this->featureContext->getPasswordForUser($asUser); $destinationPath = \trim($destinationPath, '/'); @@ -834,7 +883,13 @@ private function sendUndeleteRequest(string $user, string $trashItemHRef, string * @throws JsonException * @throws GuzzleException */ - private function restoreElement(string $user, string $originalPath, ?string $destinationPath = null, ?string $asUser = null, ?string $password = null):ResponseInterface { + private function restoreElement( + string $user, + string $originalPath, + ?string $destinationPath = null, + ?string $asUser = null, + ?string $password = null + ): ResponseInterface { $asUser = $asUser ?? $user; $listing = $this->listTrashbinFolder($user); $originalPath = \trim($originalPath, '/'); @@ -870,7 +925,10 @@ private function restoreElement(string $user, string $originalPath, ?string $des * @return void * @throws Exception */ - public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi(string $user, string $originalPath):void { + public function userRestoresResourceWithOriginalPathWithoutSpecifyingDestinationUsingTrashbinApi( + string $user, + string $originalPath + ): void { $listing = $this->listTrashbinFolder($user); $originalPath = \trim($originalPath, '/'); @@ -912,7 +970,7 @@ public function contentOfFileForUserIfAlsoInTrashShouldBeOtherwise( ?string $user, ?string $content, ?string $alternativeContent - ):void { + ): void { $isInTrash = $this->isInTrash($user, $fileName); $user = $this->featureContext->getActualUsername($user); $response = $this->featureContext->downloadFileAsUserUsingPassword($user, $fileName); @@ -933,7 +991,7 @@ public function contentOfFileForUserIfAlsoInTrashShouldBeOtherwise( * @throws JsonException * @throws Exception */ - public function elementInTrashIsRestored(?string $user, string $originalPath):void { + public function elementInTrashIsRestored(?string $user, string $originalPath): void { $user = $this->featureContext->getActualUsername($user); $this->featureContext->setResponse($this->restoreElement($user, $originalPath)); } @@ -947,7 +1005,7 @@ public function elementInTrashIsRestored(?string $user, string $originalPath):vo * @return void * @throws Exception */ - public function userRestoresFollowingFiles(string $user, TableNode $table):void { + public function userRestoresFollowingFiles(string $user, TableNode $table): void { $this->featureContext->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -967,7 +1025,7 @@ public function userRestoresFollowingFiles(string $user, TableNode $table):void * @return void * @throws Exception */ - public function elementInTrashHasBeenRestored(string $user, string $originalPath):void { + public function elementInTrashHasBeenRestored(string $user, string $originalPath): void { $response = $this->restoreElement($user, $originalPath); $this->featureContext->theHTTPStatusCodeShouldBe(201, "", $response); if ($this->isInTrash($user, $originalPath)) { @@ -990,7 +1048,7 @@ public function userRestoresTheFileWithOriginalPathToUsingTheTrashbinApi( ?string $user, ?string $originalPath, ?string $destinationPath - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $this->featureContext->setResponse($this->restoreElement($user, $originalPath, $destinationPath)); } @@ -1008,7 +1066,7 @@ public function userRestoresTheFileWithOriginalPathToUsingTheTrashbinApi( public function elementIsInTrashCheckingOriginalPath( ?string $user, ?string $originalPath - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); Assert::assertTrue( $this->isInTrash($user, $originalPath), @@ -1028,7 +1086,7 @@ public function elementIsInTrashCheckingOriginalPath( public function elementIsNotInTrashCheckingOriginalPath( ?string $user, string $originalPath - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); Assert::assertFalse( $this->isInTrash($user, $originalPath), @@ -1048,7 +1106,7 @@ public function elementIsNotInTrashCheckingOriginalPath( public function followingElementsAreNotInTrashCheckingOriginalPath( string $user, TableNode $table - ):void { + ): void { $this->featureContext->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -1073,7 +1131,7 @@ public function followingElementsAreNotInTrashCheckingOriginalPath( public function followingElementsAreInTrashCheckingOriginalPath( string $user, TableNode $table - ):void { + ): void { $this->featureContext->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -1095,7 +1153,7 @@ public function followingElementsAreInTrashCheckingOriginalPath( * @return array|null real entry name with timestamp suffix or null if not found * @throws Exception */ - private function findFirstTrashedEntry(string $user, string $name):?array { + private function findFirstTrashedEntry(string $user, string $name): ?array { $listing = $this->listTrashbinFolder($user); foreach ($listing as $entry) { @@ -1117,7 +1175,7 @@ private function findFirstTrashedEntry(string $user, string $name):?array { * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context @@ -1131,7 +1189,7 @@ public function before(BeforeScenarioScope $scope):void { * * @return void */ - public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource):void { + public function theDeletedFileFolderShouldHaveCorrectDeletionMtimeInTheResponse(string $resource): void { $files = $this->getTrashbinContentFromResponseXml( HttpRequestHelper::getResponseXml($this->featureContext->getResponse()) ); diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index 5d0b0b12764..43f5df92d28 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -99,21 +99,21 @@ public function setFilePreviewContent(string $user, string $previewContent): voi /** * @return void */ - public function davPropfindDepthInfinityEnabled():void { + public function davPropfindDepthInfinityEnabled(): void { $this->davPropfindDepthInfinityEnabled = true; } /** * @return void */ - public function davPropfindDepthInfinityDisabled():void { + public function davPropfindDepthInfinityDisabled(): void { $this->davPropfindDepthInfinityEnabled = false; } /** * @return bool */ - public function davPropfindDepthInfinityIsEnabled():bool { + public function davPropfindDepthInfinityIsEnabled(): bool { return $this->davPropfindDepthInfinityEnabled; } @@ -122,14 +122,14 @@ public function davPropfindDepthInfinityIsEnabled():bool { * * @return void */ - public function setLastUploadDeleteTime(int $lastUploadDeleteTime):void { + public function setLastUploadDeleteTime(int $lastUploadDeleteTime): void { $this->lastUploadDeleteTime = $lastUploadDeleteTime; } /** * @return number */ - public function getLastUploadDeleteTime():int { + public function getLastUploadDeleteTime(): int { return $this->lastUploadDeleteTime; } @@ -138,14 +138,14 @@ public function getLastUploadDeleteTime():int { * * @return void */ - public function setStoredFileID(string $fileID):void { + public function setStoredFileID(string $fileID): void { $this->storedFileID = $fileID; } /** * @return string */ - public function getStoredFileID():string { + public function getStoredFileID(): string { return $this->storedFileID; } @@ -185,7 +185,7 @@ public function isEtagValid(string $eTag): bool { * * @return void */ - public function usingOldOrNewOrSpacesDavPath(string $davChoice):void { + public function usingOldOrNewOrSpacesDavPath(string $davChoice): void { switch ($davChoice) { case 'old': $this->currentDAVPath = WebDavHelper::DAV_VERSION_OLD; @@ -198,7 +198,6 @@ public function usingOldOrNewOrSpacesDavPath(string $davChoice):void { break; default: throw new Exception("Invalid DAV path: $davChoice"); - break; } } @@ -213,7 +212,7 @@ public function usingOldOrNewOrSpacesDavPath(string $davChoice):void { * @return string * @throws GuzzleException */ - public function getFullDavFilesPath(string $user, ?string $spaceId = null):string { + public function getFullDavFilesPath(string $user, ?string $spaceId = null): string { if ($spaceId === null && $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { $spaceId = WebDavHelper::getPersonalSpaceIdForUser( $this->getBaseUrl(), @@ -240,7 +239,7 @@ public function getFullDavFilesPath(string $user, ?string $spaceId = null):strin * * @return string */ - public function getPublicLinkDavPath(string $token):string { + public function getPublicLinkDavPath(string $token): string { $davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files"); $path = "{$this->getBasePath()}/$davPath"; $path = WebDavHelper::sanitizeUrl($path); @@ -257,7 +256,7 @@ public function getPublicLinkDavPath(string $token):string { * * @return int DAV path version (1, 2 or 3) selected, or appropriate for the endpoint */ - public function getDavPathVersion(?string $for = null):?int { + public function getDavPathVersion(?string $for = null): ?int { if (\in_array($for, ['systemtags', 'file_versions'])) { // 'systemtags' only exists since new DAV // 'file_versions' only exists since new DAV @@ -301,7 +300,7 @@ public function makeDavRequest( ?array $urlParameter = [], ?string $doDavRequestAsUser = null, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); if ($davPathVersion === null) { @@ -349,7 +348,13 @@ public function makeDavRequest( * @throws JsonException | GuzzleException * @throws GuzzleException | JsonException */ - public function createFolder(string $user, string $folder, ?bool $isGivenStep = false, ?string $password = null, ?string $spaceId=null): ResponseInterface { + public function createFolder( + string $user, + string $folder, + ?bool $isGivenStep = false, + ?string $password = null, + ?string $spaceId=null + ): ResponseInterface { return $this->makeDavRequest( $user, "MKCOL", @@ -377,7 +382,13 @@ public function createFolder(string $user, string $folder, ?bool $isGivenStep = * @return ResponseInterface * @throws GuzzleException */ - public function downloadPreviews(string $user, ?string $path, ?string $doDavRequestAsUser, ?string $width, ?string $height):ResponseInterface { + public function downloadPreviews( + string $user, + ?string $path, + ?string $doDavRequestAsUser, + ?string $width, + ?string $height + ): ResponseInterface { $user = $this->getActualUsername($user); $doDavRequestAsUser = $this->getActualUsername($doDavRequestAsUser); $doDavRequestAsUser = $doDavRequestAsUser ?? $user; @@ -411,7 +422,7 @@ public function downloadPreviews(string $user, ?string $path, ?string $doDavRequ * @return void * @throws Exception */ - public function theNumberOfVersionsShouldBe(int $number):void { + public function theNumberOfVersionsShouldBe(int $number): void { $responseXmlObject = HttpRequestHelper::getResponseXml($this->getResponse(), __METHOD__); $xmlPart = $responseXmlObject->xpath("//d:getlastmodified"); $actualNumber = \count($xmlPart); @@ -430,7 +441,7 @@ public function theNumberOfVersionsShouldBe(int $number):void { * @return void * @throws Exception */ - public function theNumberOfEtagElementInTheResponseShouldBe(int $number):void { + public function theNumberOfEtagElementInTheResponseShouldBe(int $number): void { $responseXmlObject = HttpRequestHelper::getResponseXml($this->getResponse()); $xmlPart = $responseXmlObject->xpath("//d:getetag"); $actualNumber = \count($xmlPart); @@ -448,7 +459,7 @@ public function theNumberOfEtagElementInTheResponseShouldBe(int $number):void { * @return string * @throws GuzzleException */ - public function destinationHeaderValue(string $user, string $fileDestination):string { + public function destinationHeaderValue(string $user, string $fileDestination): string { $fileDestination = \ltrim($fileDestination, "/"); $spaceId = $this->getPersonalSpaceIdForUser($user); // If the destination is a share, we need to get the space ID for the Shares space @@ -483,7 +494,7 @@ public function userHasMovedFile( ?string $user, ?string $fileSource, ?string $fileDestination - ):void { + ): void { $response = $this->moveResource($user, $fileSource, $fileDestination); $actualStatusCode = $response->getStatusCode(); $this->theHTTPStatusCodeShouldBe( @@ -531,7 +542,7 @@ public function userMovesFileOrFolderUsingTheWebDavAPI( string $user, string $source, string $destination - ):void { + ): void { $response = $this->moveResource($user, $source, $destination); $this->setResponse($response); $this->pushToLastHttpStatusCodesArray(); @@ -546,7 +557,7 @@ public function userMovesFileOrFolderUsingTheWebDavAPI( * @return void * @throws Exception */ - public function userMovesTheFollowingFileUsingTheWebdavApi(string $user, TableNode $table):void { + public function userMovesTheFollowingFileUsingTheWebdavApi(string $user, TableNode $table): void { $this->verifyTableNodeColumns($table, ["source", "destination"]); $rows = $table->getHash(); foreach ($rows as $row) { @@ -572,7 +583,7 @@ public function userMovesFollowingFileUsingTheAPI( string $user, string $type, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["from", "to"]); $paths = $table->getHash(); @@ -595,7 +606,12 @@ public function userMovesFollowingFileUsingTheAPI( * @return void * @throws Exception */ - public function theUserShouldBeAbleToRenameEntryTo(string $user, string $entry, string $source, string $destination):void { + public function theUserShouldBeAbleToRenameEntryTo( + string $user, + string $entry, + string $source, + string $destination + ): void { $user = $this->getActualUsername($user); $this->checkFileOrFolderExistsForUser($user, $entry, $source); $response = $this->moveResource($user, $source, $destination); @@ -615,7 +631,12 @@ public function theUserShouldBeAbleToRenameEntryTo(string $user, string $entry, * @return void * @throws Exception */ - public function theUserShouldNotBeAbleToRenameEntryTo(string $user, string $entry, string $source, string $destination):void { + public function theUserShouldNotBeAbleToRenameEntryTo( + string $user, + string $entry, + string $source, + string $destination + ): void { $this->checkFileOrFolderExistsForUser($user, $entry, $source); $response = $this->moveResource($user, $source, $destination); $this->theHTTPStatusCodeShouldBeBetween(400, 499, $response); @@ -634,7 +655,7 @@ public function copyFile( string $user, string $fileSource, string $fileDestination - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $headers['Destination'] = $this->destinationHeaderValue( $user, @@ -661,7 +682,7 @@ public function userCopiesFileUsingTheAPI( string $user, string $fileSource, string $fileDestination - ):void { + ): void { $response = $this->copyFile($user, $fileSource, $fileDestination); $this->setResponse($response); $this->pushToLastHttpStatusCodesArray(); @@ -680,11 +701,12 @@ public function userHasCopiedFileUsingTheAPI( string $user, string $fileSource, string $fileDestination - ):void { + ): void { $response = $this->copyFile($user, $fileSource, $fileDestination); $this->theHTTPStatusCodeShouldBe( ["201", "204"], - "HTTP status code was not 201 or 204 while trying to copy resource '$fileSource' to '$fileDestination' for user '$user'", + "HTTP status code was not 201 or 204 while trying to copy resource " + . "'$fileSource' to '$fileDestination' for user '$user'", $response ); } @@ -696,7 +718,7 @@ public function userHasCopiedFileUsingTheAPI( * * @return ResponseInterface */ - public function downloadFileWithRange(string $user, string $fileSource, string $range):ResponseInterface { + public function downloadFileWithRange(string $user, string $fileSource, string $range): ResponseInterface { $user = $this->getActualUsername($user); $headers['Range'] = $range; return $this->makeDavRequest( @@ -716,7 +738,7 @@ public function downloadFileWithRange(string $user, string $fileSource, string $ * * @return void */ - public function userDownloadsFileWithRangeUsingWebDavApi(string $user, string $fileSource, string $range):void { + public function userDownloadsFileWithRangeUsingWebDavApi(string $user, string $fileSource, string $range): void { $this->setResponse($this->downloadFileWithRange($user, $fileSource, $range)); } @@ -733,7 +755,7 @@ public function userUsingPasswordShouldNotBeAbleToDownloadFile( string $user, string $password, string $fileName - ):void { + ): void { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); $response = $this->downloadFileAsUserUsingPassword($user, $fileName, $password); @@ -764,7 +786,7 @@ public function userUsingPasswordShouldNotBeAbleToDownloadFile( public function userShouldNotBeAbleToDownloadFile( string $user, string $fileName - ):void { + ): void { $user = $this->getActualUsername($user); $password = $this->getPasswordForUser($user); $response = $this->downloadFileAsUserUsingPassword($user, $fileName, $password); @@ -790,7 +812,7 @@ public function userShouldNotBeAbleToDownloadFile( * * @return void */ - public function sizeOfDownloadedFileShouldBe(string $size):void { + public function sizeOfDownloadedFileShouldBe(string $size): void { $actualSize = \strlen((string) $this->response->getBody()); Assert::assertEquals( $size, @@ -806,7 +828,7 @@ public function sizeOfDownloadedFileShouldBe(string $size):void { * * @return void */ - public function downloadedContentShouldEndWith(string $content):void { + public function downloadedContentShouldEndWith(string $content): void { $actualContent = \substr((string) $this->response->getBody(), -\strlen($content)); Assert::assertEquals( $content, @@ -822,7 +844,7 @@ public function downloadedContentShouldEndWith(string $content):void { * * @return void */ - public function downloadedContentShouldBe(string $content):void { + public function downloadedContentShouldBe(string $content): void { $this->checkDownloadedContentMatches($content, '', $this->getResponse()); } @@ -837,7 +859,7 @@ public function checkDownloadedContentMatches( string $expectedContent, string $extraErrorText = "", ?ResponseInterface $response = null - ):void { + ): void { $response = $response ?? $this->response; $actualContent = (string) $response->getBody(); // For this test we really care about the content. @@ -851,7 +873,8 @@ public function checkDownloadedContentMatches( Assert::assertEquals( $expectedContent, $actualContent, - $extraErrorText . "The content was expected to be '$expectedContent', but actually is '$actualContent'. HTTP status was $actualStatus" + $extraErrorText . "The content was expected to be '$expectedContent', but actually is " + . "'$actualContent'. HTTP status was $actualStatus" ); } @@ -889,7 +912,7 @@ public function theContentInTheResponseShouldIncludeTheFollowingContent(PyString * @return void * */ - public function theDownloadedContentForMultipartByteRangeShouldBe(int $statusCode, PyStringNode $content):void { + public function theDownloadedContentForMultipartByteRangeShouldBe(int $statusCode, PyStringNode $content): void { $actualStatusCode = $this->response->getStatusCode(); if ($actualStatusCode === $statusCode) { $actualContent = (string) $this->response->getBody(); @@ -899,7 +922,8 @@ public function theDownloadedContentForMultipartByteRangeShouldBe(int $statusCod Assert::assertEquals( $content, $actualContent, - "The downloaded content was expected to be '$content', but actually is '$actualContent'. HTTP status was $actualStatusCode" + "The downloaded content was expected to be '$content', but actually is " + . "'$actualContent'. HTTP status was $actualStatusCode" ); } } @@ -912,7 +936,7 @@ public function theDownloadedContentForMultipartByteRangeShouldBe(int $statusCod * * @return void */ - public function checkStatusCodeForDownloadedContentShouldBe(int $statusCode, string $content):void { + public function checkStatusCodeForDownloadedContentShouldBe(int $statusCode, string $content): void { $actualStatusCode = $this->response->getStatusCode(); if ($actualStatusCode === $statusCode) { $this->checkDownloadedContentMatches($content, '', $this->getResponse()); @@ -928,7 +952,7 @@ public function checkStatusCodeForDownloadedContentShouldBe(int $statusCode, str * * @return void */ - public function contentOfFileForUserShouldBe(string $fileName, string $user, string $content):void { + public function contentOfFileForUserShouldBe(string $fileName, string $user, string $content): void { $response = $this->downloadFileAsUserUsingPassword($this->getActualUsername($user), $fileName); $actualStatus = $response->getStatusCode(); if ($actualStatus !== 200) { @@ -949,7 +973,7 @@ public function contentOfFileForUserShouldBe(string $fileName, string $user, str * @return void * @throws Exception */ - public function contentOfFollowingFilesShouldBe(string $user, string $content, TableNode $table):void { + public function contentOfFollowingFilesShouldBe(string $user, string $content, TableNode $table): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -981,7 +1005,7 @@ public function contentOfFileForUserUsingPasswordShouldBe( string $user, ?string $password, string $content - ):void { + ): void { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); $response = $this->downloadFileAsUserUsingPassword($user, $fileName, $password); @@ -1001,7 +1025,7 @@ public function contentOfFileForUserShouldBePyString( string $fileName, string $user, PyStringNode $content - ):void { + ): void { $user = $this->getActualUsername($user); $response = $this->downloadFileAsUserUsingPassword($user, $fileName); $actualStatus = $response->getStatusCode(); @@ -1025,7 +1049,7 @@ public function contentOfFileForUserShouldBePyString( public function userDownloadsFileUsingTheAPI( string $user, string $fileName - ):void { + ): void { $this->setResponse($this->downloadFileAsUserUsingPassword($user, $fileName)); } @@ -1044,7 +1068,7 @@ public function downloadFileAsUserUsingPassword( ?string $password = null, ?array $headers = [], ?string $spaceId = null, - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $password = $this->getActualPassword($password); return $this->makeDavRequest( @@ -1067,8 +1091,9 @@ public function downloadFileAsUserUsingPassword( * @return void * @throws Exception */ - public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi():void { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi(): void { + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $davPath = WebDavHelper::getDavPath($this->getDavPathVersion(), $token, "public-files"); $url = "{$this->getBaseUrl()}/$davPath"; $this->response = HttpRequestHelper::sendRequest( @@ -1087,7 +1112,7 @@ public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi():void { * @return void * @throws Exception */ - public function userGetsSizeOfFileUsingTheWebdavApi(string $user, string $resource):void { + public function userGetsSizeOfFileUsingTheWebdavApi(string $user, string $resource): void { $user = $this->getActualUsername($user); $password = $this->getPasswordForUser($user); $this->response = WebDavHelper::propfind( @@ -1112,7 +1137,7 @@ public function userGetsSizeOfFileUsingTheWebdavApi(string $user, string $resour * @return void * @throws Exception */ - public function theSizeOfTheFileShouldBe(string $size):void { + public function theSizeOfTheFileShouldBe(string $size): void { $responseXmlObject = HttpRequestHelper::getResponseXml( $this->response, __METHOD__ @@ -1136,7 +1161,7 @@ public function theSizeOfTheFileShouldBe(string $size):void { * * @return void */ - public function contentOfFileForUserShouldBePlusEndOfLine(string $fileName, string $user, string $content):void { + public function contentOfFileForUserShouldBePlusEndOfLine(string $fileName, string $user, string $content): void { $user = $this->getActualUsername($user); $response = $this->downloadFileAsUserUsingPassword($user, $fileName); $actualStatus = $response->getStatusCode(); @@ -1156,7 +1181,7 @@ public function contentOfFileForUserShouldBePlusEndOfLine(string $fileName, stri * @return void * @throws Exception */ - public function theFollowingHeadersShouldBeSet(TableNode $table):void { + public function theFollowingHeadersShouldBeSet(TableNode $table): void { $this->verifyTableNodeColumns( $table, ['header', 'value'] @@ -1200,7 +1225,7 @@ public function asFileOrFolderShouldNotExist( string $user, string $entry, string $path - ):void { + ): void { $this->checkFileOrFolderDoesNotExistsForUser($user, $entry, $path); } @@ -1217,7 +1242,7 @@ public function checkFileOrFolderDoesNotExistsForUser( string $entry = "file", ?string $path = null, string $type = "files" - ):void { + ): void { $user = $this->getActualUsername($user); $path = $this->substituteInLineCodes($path); $response = $this->listFolder( @@ -1273,7 +1298,7 @@ public function followingFilesShouldNotExist( string $user, string $entry, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); $entry = \rtrim($entry, "s"); @@ -1297,7 +1322,7 @@ public function asFileOrFolderShouldExist( string $user, string $entry, string $path - ):void { + ): void { $this->checkFileOrFolderExistsForUser($user, $entry, $path); } @@ -1315,7 +1340,7 @@ public function checkFileOrFolderExistsForUser( string $entry, string $path, ?string $type = "files" - ):void { + ): void { $user = $this->getActualUsername($user); $path = $this->substituteInLineCodes($path); $responseXmlObject = HttpRequestHelper::getResponseXml( @@ -1355,7 +1380,7 @@ public function followingFilesOrFoldersShouldExist( string $user, string $entry, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); $entry = \rtrim($entry, "s"); @@ -1379,7 +1404,7 @@ public function fileOrFolderExists( string $entry, string $path, string $type = "files" - ):bool { + ): bool { try { $this->checkFileOrFolderExistsForUser($user, $entry, $path, $type); return true; @@ -1407,7 +1432,7 @@ public function listFolder( ?array $properties = null, ?string $spaceId = null, string $type = "files" - ):ResponseInterface { + ): ResponseInterface { return WebDavHelper::listFolder( $this->getBaseUrl(), $this->getActualUsername($user), @@ -1433,7 +1458,7 @@ public function listFolder( * @throws InvalidArgumentException|Exception * */ - public function userShouldSeeTheElements(string $user, string $shouldOrNot, TableNode $elements):void { + public function userShouldSeeTheElements(string $user, string $shouldOrNot, TableNode $elements): void { $should = ($shouldOrNot !== "not"); $this->checkElementList($user, $elements, $should); } @@ -1454,7 +1479,7 @@ public function checkElementList( string $user, TableNode $elements, bool $expectedToBeListed = true - ):void { + ): void { $user = $this->getActualUsername($user); $this->verifyTableNodeColumnsCount($elements, 1); $elementRows = $elements->getRows(); @@ -1552,7 +1577,7 @@ public function uploadFile( string $destination, string $spaceId = null, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $file = \fopen($this->acceptanceTestsDirLocation() . $source, 'r'); $this->pauseUploadDelete(); @@ -1588,7 +1613,7 @@ public function userUploadsAFileToUsingWebDavApi( string $user, string $source, string $destination - ):void { + ): void { $response = $this->uploadFile($user, $source, $destination); $this->setResponse($response); $this->pushToLastHttpStatusCodesArray( @@ -1605,11 +1630,12 @@ public function userUploadsAFileToUsingWebDavApi( * * @return array */ - public function userHasUploadedAFileTo(string $user, string $source, string $destination):array { + public function userHasUploadedAFileTo(string $user, string $source, string $destination): array { $response = $this->uploadFile($user, $source, $destination, null, true); $this->theHTTPStatusCodeShouldBe( ["201", "204"], - "HTTP status code was not 201 or 204 while trying to upload file '$source' to '$destination' for user '$user'", + "HTTP status code was not 201 or 204 while trying to upload file " + . "'$source' to '$destination' for user '$user'", $response ); return $response->getHeader('oc-fileid'); @@ -1709,7 +1735,7 @@ public function userUploadsAFileToWithChunks( string $source, string $destination, int $noOfChunks = 2 - ):void { + ): void { $response = $this->userUploadsAFileInChunk($user, $source, $destination, $noOfChunks); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -1723,7 +1749,7 @@ public function userUploadsAFileToWithChunks( * @return void * @throws Exception */ - public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe(int $statusCode):void { + public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe(int $statusCode): void { $duplicateRemovedStatusCodes = \array_unique($this->lastHttpStatusCodesArray); if (\count($duplicateRemovedStatusCodes) === 1) { Assert::assertSame( @@ -1746,7 +1772,7 @@ public function theHTTPStatusCodeOfResponsesOnAllEndpointsShouldBe(int $statusCo * @return void * @throws Exception */ - public function checkTheHTTPStatusCodeOfResponsesOnEachEndpoint(string $statusCodes):void { + public function checkTheHTTPStatusCodeOfResponsesOnEachEndpoint(string $statusCodes): void { $expectedStatusCodes = \explode(',', $statusCodes); $actualStatusCodes = $this->lastHttpStatusCodesArray; $count = \count($expectedStatusCodes); @@ -1778,7 +1804,7 @@ public function checkTheHTTPStatusCodeOfResponsesOnEachEndpoint(string $statusCo * @return void * @throws Exception */ - public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusCodes):void { + public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusCodes): void { $this->checkTheHTTPStatusCodeOfResponsesOnEachEndpoint($statusCodes); } @@ -1791,7 +1817,10 @@ public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBe(string $statu * @return void * @throws Exception */ - public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(string $ocisStatusCodes, string $revaStatusCodes):void { + public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva( + string $ocisStatusCodes, + string $revaStatusCodes + ): void { if (OcisHelper::isTestingOnReva()) { $expectedStatusCodes = $revaStatusCodes; } else { @@ -1808,7 +1837,7 @@ public function theHTTPStatusCodeOfResponsesOnEachEndpointShouldBeOcisReva(strin * @return void * @throws Exception */ - public function theOCStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusCodes):void { + public function theOCStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusCodes): void { $statusCodes = \explode(',', $statusCodes); $count = \count($statusCodes); if ($count === \count($this->lastOCSStatusCodesArray)) { @@ -1835,7 +1864,7 @@ public function theOCStatusCodeOfResponsesOnEachEndpointShouldBe(string $statusC * @return void * @throws Exception */ - public function theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe(string $statusCode):void { + public function theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe(string $statusCode): void { $duplicateRemovedStatusCodes = \array_unique($this->lastOCSStatusCodesArray); if (\count($duplicateRemovedStatusCodes) === 1) { Assert::assertSame( @@ -1862,7 +1891,7 @@ public function theOCSStatusCodeOfResponsesOnAllEndpointsShouldBe(string $status * @return void * @throws Exception */ - public function userShouldBeAbleToUploadFileTo(string $user, string $source, string $destination):void { + public function userShouldBeAbleToUploadFileTo(string $user, string $source, string $destination): void { $user = $this->getActualUsername($user); $response = $this->uploadFile($user, $source, $destination); $this->theHTTPStatusCodeShouldBe( @@ -1883,7 +1912,7 @@ public function userShouldBeAbleToUploadFileTo(string $user, string $source, str * @return void * @throws Exception */ - public function theUserShouldNotBeAbleToUploadFileTo(string $user, string $source, string $destination):void { + public function theUserShouldNotBeAbleToUploadFileTo(string $user, string $source, string $destination): void { $fileAlreadyExists = $this->fileOrFolderExists($user, "file", $destination); if ($fileAlreadyExists) { $response = $this->downloadFileAsUserUsingPassword($user, $destination); @@ -1897,7 +1926,8 @@ public function theUserShouldNotBeAbleToUploadFileTo(string $user, string $sourc Assert::assertSame( $initialContent, $currentContent, - __METHOD__ . " user $user was unexpectedly able to upload $source to $destination - the content has changed:" + __METHOD__ + . " user $user was unexpectedly able to upload $source to $destination - the content has changed:" ); } else { $this->checkFileOrFolderDoesNotExistsForUser($user, "file", $destination); @@ -1917,7 +1947,7 @@ public function checkIfFilesExist( string $destination, string $shouldOrNot, ?string $exceptChunkingType = '' - ):void { + ): void { switch ($exceptChunkingType) { case 'old': $exceptChunkingSuffix = 'olddav-oldchunking'; @@ -1967,7 +1997,7 @@ public function checkIfFilesExist( * @return void * @throws Exception */ - public function userHasUploadedFileToOfSizeBytes(string $user, string $destination, string $bytes):void { + public function userHasUploadedFileToOfSizeBytes(string $user, string $destination, string $bytes): void { $user = $this->getActualUsername($user); $filename = "filespecificSize.txt"; $this->createLocalFileOfSpecificSize($filename, $bytes, 'a'); @@ -1989,7 +2019,12 @@ public function userHasUploadedFileToOfSizeBytes(string $user, string $destinati * @return void * @throws Exception */ - public function userHasUploadedFileToEndingWithOfSizeBytes(string $user, string $destination, string $text, string $bytes):void { + public function userHasUploadedFileToEndingWithOfSizeBytes( + string $user, + string $destination, + string $text, + string $bytes + ): void { $filename = "filespecificSize.txt"; $this->createLocalFileOfSpecificSize($filename, $bytes, $text); Assert::assertFileExists($this->workStorageDirLocation() . $filename); @@ -2021,7 +2056,9 @@ public function uploadFileWithContent( $user = $this->getActualUsername($user); $this->pauseUploadDelete(); - if (\str_starts_with($destination, "Shares/") && $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { + if (\str_starts_with($destination, "Shares/") + && $this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES + ) { $spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares"); $destination = \str_replace("Shares/", "", $destination); } @@ -2059,7 +2096,7 @@ public function userUploadsAFileWithContentTo( string $user, ?string $content, string $destination - ):void { + ): void { $response = $this->uploadFileWithContent($user, $content, $destination); $this->setResponse($response); $this->pushToLastHttpStatusCodesArray(); @@ -2079,7 +2116,7 @@ public function userUploadsFollowingFilesWithContentTo( string $user, ?string $content, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -2108,7 +2145,7 @@ public function userUploadsFileToWithMtimeUsingTheWebdavApi( string $destination, string $mtime, ?bool $isGivenStep = false - ):void { + ): void { $mtime = new DateTime($mtime); $mtime = $mtime->format('U'); $user = $this->getActualUsername($user); @@ -2143,7 +2180,7 @@ public function userHasUploadedFileToWithMtimeUsingTheWebdavApi( string $source, string $destination, string $mtime - ):void { + ): void { $mtime = new DateTime($mtime); $mtime = $mtime->format('U'); $user = $this->getActualUsername($user); @@ -2181,7 +2218,7 @@ public function theMtimeOfTheFileShouldBe( string $user, string $resource, string $mtime - ):void { + ): void { $user = $this->getActualUsername($user); $password = $this->getPasswordForUser($user); $baseUrl = $this->getBaseUrl(); @@ -2215,7 +2252,7 @@ public function userHasUploadedAFileWithContentTo( string $user, ?string $content, string $destination - ):array { + ): array { $user = $this->getActualUsername($user); $response = $this->uploadFileWithContent($user, $content, $destination, null, true); $this->theHTTPStatusCodeShouldBe( @@ -2240,7 +2277,7 @@ public function userHasUploadedFollowingFilesWithContent( string $user, ?string $content, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $files = $table->getHash(); @@ -2268,7 +2305,7 @@ public function userHasUploadedFollowingFilesWithContent( public function userDownloadsFollowingFiles( string $user, TableNode $table - ):void { + ): void { $this->verifyTableNodeColumns($table, ["path"]); $files = $table->getHash(); $this->emptyLastHTTPStatusCodesArray(); @@ -2295,7 +2332,7 @@ public function userUploadsAFileWithContentAndMtimeTo( ?string $content, string $mtime, string $destination - ):void { + ): void { $user = $this->getActualUsername($user); $mtime = new DateTime($mtime); $mtime = $mtime->format('U'); @@ -2326,7 +2363,7 @@ public function uploadFileWithChecksumAndContent( string $destination, ?bool $isGivenStep = false, ?string $spaceId = null - ):ResponseInterface { + ): ResponseInterface { $this->pauseUploadDelete(); $response = $this->makeDavRequest( $user, @@ -2362,7 +2399,7 @@ public function userUploadsAFileWithChecksumAndContentTo( string $checksum, string $content, string $destination - ):void { + ): void { $response = $this->uploadFileWithChecksumAndContent($user, $checksum, $content, $destination); $this->setResponse($response); } @@ -2382,7 +2419,7 @@ public function userHasUploadedAFileWithChecksumAndContentTo( string $checksum, ?string $content, string $destination - ):void { + ): void { $response = $this->uploadFileWithChecksumAndContent( $user, $checksum, @@ -2392,7 +2429,8 @@ public function userHasUploadedAFileWithChecksumAndContentTo( ); $this->theHTTPStatusCodeShouldBe( ["201", "204"], - "HTTP status code was not 201 or 204 while trying to upload file with checksum '$checksum' to '$destination' for user '$user'", + "HTTP status code was not 201 or 204 while trying to upload file with checksum " + . "'$checksum' to '$destination' for user '$user'", $response ); } @@ -2407,7 +2445,7 @@ public function userHasUploadedAFileWithChecksumAndContentTo( * @return void * @throws Exception */ - public function userShouldBeAbleToDeleteEntry(string $user, string $entry, string $source):void { + public function userShouldBeAbleToDeleteEntry(string $user, string $entry, string $source): void { $user = $this->getActualUsername($user); $this->checkFileOrFolderExistsForUser($user, $entry, $source); $this->deleteFile($user, $source); @@ -2424,7 +2462,7 @@ public function userShouldBeAbleToDeleteEntry(string $user, string $entry, strin * @return void * @throws Exception */ - public function theUserShouldNotBeAbleToDeleteEntry(string $user, string $entry, string $source):void { + public function theUserShouldNotBeAbleToDeleteEntry(string $user, string $entry, string $source): void { $this->checkFileOrFolderExistsForUser($user, $entry, $source); $this->deleteFile($user, $source); $this->checkFileOrFolderExistsForUser($user, $entry, $source); @@ -2436,7 +2474,7 @@ public function theUserShouldNotBeAbleToDeleteEntry(string $user, string $entry, * * @return void */ - public function deleteFile(string $user, string $resource):ResponseInterface { + public function deleteFile(string $user, string $resource): ResponseInterface { $user = $this->getActualUsername($user); $this->pauseUploadDelete(); $response = $this->makeDavRequest($user, 'DELETE', $resource, []); @@ -2452,7 +2490,7 @@ public function deleteFile(string $user, string $resource):ResponseInterface { * * @return void */ - public function userDeletesFile(string $user, string $resource):void { + public function userDeletesFile(string $user, string $resource): void { $response = $this->deleteFile($user, $resource); $this->setResponse($response); $this->pushToLastStatusCodesArrays(); @@ -2468,7 +2506,12 @@ public function userDeletesFile(string $user, string $resource):void { * * @return void */ - public function userDeletesFileFromSpaceUsingFileIdPath(string $user, string $filename, string $space, string $fileId):void { + public function userDeletesFileFromSpaceUsingFileIdPath( + string $user, + string $filename, + string $space, + string $fileId + ): void { $baseUrl = $this->getBaseUrl(); $davPath = WebDavHelper::getDavPath($this->getDavPathVersion()); $user = $this->getActualUsername($user); @@ -2519,7 +2562,7 @@ public function userHasUpdatedAFileWithContentUsingFileId(string $user, string $ * @return void * @throws Exception */ - public function userHasDeletedResource(string $user, string $resource):void { + public function userHasDeletedResource(string $user, string $resource): void { $user = $this->getActualUsername($user); $response = $this->deleteFile($user, $resource); // If the file or folder was there and got deleted then we get a 204 @@ -2545,7 +2588,7 @@ public function userHasDeletedResource(string $user, string $resource):void { * @return void * @throws Exception */ - public function userHasDeletedFollowingFiles(string $user, TableNode $table):void { + public function userHasDeletedFollowingFiles(string $user, TableNode $table): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -2570,7 +2613,7 @@ public function userHasDeletedFollowingFiles(string $user, TableNode $table):voi * @return void * @throws Exception */ - public function userDeletesFollowingFiles(string $user, TableNode $table):void { + public function userDeletesFollowingFiles(string $user, TableNode $table): void { $user = $this->getActualUsername($user); $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -2592,7 +2635,7 @@ public function userDeletesFollowingFiles(string $user, TableNode $table):void { * @return void * @throws Exception */ - public function userDeletesFilesFoldersWithoutDelays(string $user, TableNode $table):void { + public function userDeletesFilesFoldersWithoutDelays(string $user, TableNode $table): void { $user = $this->getActualUsername($user); $this->verifyTableNodeColumnsCount($table, 1); foreach ($table->getTable() as $entry) { @@ -2613,7 +2656,7 @@ public function userDeletesFilesFoldersWithoutDelays(string $user, TableNode $ta * @throws JsonException * @throws GuzzleException */ - public function userCreatesFolder(string $user, string $destination):void { + public function userCreatesFolder(string $user, string $destination): void { $response = $this->createFolder($user, $destination); $this->setResponse($response); } @@ -2628,7 +2671,7 @@ public function userCreatesFolder(string $user, string $destination):void { * @throws JsonException * @throws GuzzleException */ - public function userHasCreatedFolder(string $user, string $destination):void { + public function userHasCreatedFolder(string $user, string $destination): void { $user = $this->getActualUsername($user); $response = $this->createFolder($user, $destination, true); $this->theHTTPStatusCodeShouldBe( @@ -2647,7 +2690,7 @@ public function userHasCreatedFolder(string $user, string $destination):void { * @throws JsonException * @throws GuzzleException */ - public function adminHasCreatedFolder(string $destination):void { + public function adminHasCreatedFolder(string $destination): void { $admin = $this->getAdminUsername(); Assert::assertEquals( "admin", @@ -2672,7 +2715,7 @@ public function adminHasCreatedFolder(string $destination):void { * @return void * @throws Exception */ - public function userHasCreatedFollowingFolders(string $user, TableNode $table):void { + public function userHasCreatedFollowingFolders(string $user, TableNode $table): void { $this->verifyTableNodeColumns($table, ["path"]); $paths = $table->getHash(); @@ -2697,7 +2740,7 @@ public function userHasCreatedFollowingFolders(string $user, TableNode $table):v * @return void * @throws Exception */ - public function userShouldBeAbleToCreateFolder(string $user, string $destination):void { + public function userShouldBeAbleToCreateFolder(string $user, string $destination): void { $user = $this->getActualUsername($user); $response = $this->createFolder($user, $destination, true); $this->theHTTPStatusCodeShouldBe( @@ -2722,7 +2765,11 @@ public function userShouldBeAbleToCreateFolder(string $user, string $destination * @return void * @throws Exception */ - public function userShouldBeAbleToCreateFolderUsingPassword(string $user, string $destination, string $password):void { + public function userShouldBeAbleToCreateFolderUsingPassword( + string $user, + string $destination, + string $password + ): void { $user = $this->getActualUsername($user); $response = $this->createFolder($user, $destination, true, $password); $this->theHTTPStatusCodeShouldBe( @@ -2746,7 +2793,7 @@ public function userShouldBeAbleToCreateFolderUsingPassword(string $user, string * @return void * @throws Exception */ - public function userShouldNotBeAbleToCreateFolder(string $user, string $destination):void { + public function userShouldNotBeAbleToCreateFolder(string $user, string $destination): void { $user = $this->getActualUsername($user); $response = $this->createFolder($user, $destination); $this->theHTTPStatusCodeShouldBeBetween(400, 499, $response); @@ -2767,7 +2814,11 @@ public function userShouldNotBeAbleToCreateFolder(string $user, string $destinat * @return void * @throws Exception */ - public function userShouldNotBeAbleToCreateFolderUsingPassword(string $user, string $destination, string $password):void { + public function userShouldNotBeAbleToCreateFolderUsingPassword( + string $user, + string $destination, + string $password + ): void { $user = $this->getActualUsername($user); $response = $this->createFolder($user, $destination, false, $password); $this->theHTTPStatusCodeShouldBeBetween(400, 499, $response); @@ -2800,7 +2851,7 @@ public function userUploadsTheFollowingTotalChunksUsingOldChunking( string $total, string $file, TableNode $chunkDetails - ):void { + ): void { $this->verifyTableNodeColumns($chunkDetails, ['number', 'content']); foreach ($chunkDetails->getHash() as $chunkDetail) { $chunkNumber = (int)$chunkDetail['number']; @@ -2830,7 +2881,7 @@ public function userUploadsTheFollowingChunksUsingOldChunking( string $user, string $file, TableNode $chunkDetails - ):void { + ): void { $total = (string) \count($chunkDetails->getHash()); $this->verifyTableNodeColumns($chunkDetails, ['number', 'content']); foreach ($chunkDetails->getHash() as $chunkDetail) { @@ -2859,7 +2910,7 @@ public function userUploadChunkedFile( ?string $data, string $destination, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $num -= 1; $file = "$destination-chunking-42-$total-$num"; @@ -2906,7 +2957,7 @@ public function uploadTheFollowingChunksUsingNewChunking( string $file, TableNode $chunkDetails, ?bool $isGivenStep = false - ):void { + ): void { $user = $this->getActualUsername($user); $async = false; if ($type === "asynchronously") { @@ -2946,7 +2997,7 @@ public function userUploadsChunksUsingNewChunking( array $chunkDetails, bool $async = false, bool $isGivenStep = false - ):void { + ): void { $this->pauseUploadDelete(); if ($isGivenStep) { $response = $this->userCreateANewChunkingUploadWithId($user, $chunkingId, true); @@ -2958,7 +3009,13 @@ public function userUploadsChunksUsingNewChunking( $chunkNumber = (int)$chunkDetail['number']; $chunkContent = $chunkDetail['content']; if ($isGivenStep) { - $response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId, true); + $response = $this->userUploadNewChunkFileOfWithToId( + $user, + $chunkNumber, + $chunkContent, + $chunkingId, + true + ); $this->theHTTPStatusCodeShouldBeBetween(200, 299, $response); } else { $response = $this->userUploadNewChunkFileOfWithToId($user, $chunkNumber, $chunkContent, $chunkingId); @@ -2991,7 +3048,7 @@ public function userCreateANewChunkingUploadWithId( string $user, string $id, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $destination = "/uploads/$user/$id"; return $this->makeDavRequest( @@ -3026,7 +3083,7 @@ public function userUploadNewChunkFileOfWithToId( ?string $data, string $id, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $destination = "/uploads/$user/$id/$num"; return $this->makeDavRequest( @@ -3059,7 +3116,7 @@ public function userMoveNewChunkFileWithIdToMychunkedfile( string $id, string $type, string $dest - ):ResponseInterface { + ): ResponseInterface { $headers = []; if ($type === "asynchronously") { $headers = ['OC-LazyOps' => 'true']; @@ -3082,7 +3139,7 @@ public function userMovesNewChunkFileWithIdToMychunkedfile( string $id, string $type, string $dest - ):void { + ): void { $this->setResponse($this->userMoveNewChunkFileWithIdToMychunkedfile($user, $id, $type, $dest)); } @@ -3101,7 +3158,7 @@ public function userMoveNewChunkFileWithIdToMychunkedfileWithSize( string $type, string $dest, int $size - ):ResponseInterface { + ): ResponseInterface { $headers = ['OC-Total-Length' => $size]; if ($type === "asynchronously") { $headers['OC-LazyOps'] = 'true'; @@ -3129,7 +3186,7 @@ public function userMoveNewChunkFileWithIdToMychunkedfileWithChecksum( string $type, string $dest, string $checksum - ):ResponseInterface { + ): ResponseInterface { $headers = ['OC-Checksum' => $checksum]; if ($type === "asynchronously") { $headers['OC-LazyOps'] = 'true'; @@ -3159,7 +3216,7 @@ public function userHasMovedNewChunkFileWithIdToMychunkedfileWithChecksum( string $type, string $dest, string $checksum - ):void { + ): void { $response = $this->userMoveNewChunkFileWithIdToMychunkedfileWithChecksum( $user, $id, @@ -3187,7 +3244,7 @@ private function moveNewDavChunkToFinalFile( string $destination, array $headers, ?bool $isGivenStep = false - ):ResponseInterface { + ): ResponseInterface { $user = $this->getActualUsername($user); $source = "/uploads/$user/$id/.file"; $headers['Destination'] = $this->destinationHeaderValue( @@ -3221,7 +3278,7 @@ private function moveNewDavChunkToFinalFile( * * @return ResponseInterface */ - private function deleteUpload(string $user, string $id, array $headers):ResponseInterface { + private function deleteUpload(string $user, string $id, array $headers): ResponseInterface { $source = "/uploads/$user/$id"; return $this->makeDavRequest( $user, @@ -3241,7 +3298,7 @@ private function deleteUpload(string $user, string $id, array $headers):Response * * @return string encoded path */ - public function encodePath(string $path):string { + public function encodePath(string $path): string { // slashes need to stay // in ocis even brackets are encoded return \str_replace('%2F', '/', \rawurlencode($path)); @@ -3252,7 +3309,7 @@ public function encodePath(string $path):string { * * @return ResponseInterface */ - public function connectToDavEndpoint():ResponseInterface { + public function connectToDavEndpoint(): ResponseInterface { return $this->makeDavRequest( null, 'PROPFIND', @@ -3266,7 +3323,7 @@ public function connectToDavEndpoint():ResponseInterface { * * @return void */ - public function connectingToDavEndpoint():void { + public function connectingToDavEndpoint(): void { $this->setResponse($this->connectToDavEndpoint()); } @@ -3276,7 +3333,7 @@ public function connectingToDavEndpoint():void { * @return void * @throws Exception */ - public function thereAreNoDuplicateHeaders():void { + public function thereAreNoDuplicateHeaders(): void { $headers = $this->response->getHeaders(); foreach ($headers as $headerName => $headerValues) { // if a header has multiple values, they must be different @@ -3296,7 +3353,7 @@ public function thereAreNoDuplicateHeaders():void { * @return void * @throws Exception */ - public function theFollowingHeadersShouldNotBeSet(TableNode $table):void { + public function theFollowingHeadersShouldNotBeSet(TableNode $table): void { $this->verifyTableNodeColumns( $table, ['header'] @@ -3322,7 +3379,7 @@ public function theFollowingHeadersShouldNotBeSet(TableNode $table):void { * @return void * @throws Exception */ - public function theFollowingHeadersShouldMatchTheseRegularExpressions(TableNode $table):void { + public function theFollowingHeadersShouldMatchTheseRegularExpressions(TableNode $table): void { $this->headersShouldMatchRegularExpressions($table); } @@ -3331,7 +3388,7 @@ public function theFollowingHeadersShouldMatchTheseRegularExpressions(TableNode * * @return void */ - public function headersShouldMatchRegularExpressions(TableNode $table):void { + public function headersShouldMatchRegularExpressions(TableNode $table): void { $this->verifyTableNodeColumnsCount($table, 2); foreach ($table->getTable() as $header) { $headerName = $header[0]; @@ -3360,7 +3417,7 @@ public function headersShouldMatchRegularExpressions(TableNode $table):void { * @return void * @throws Exception */ - public function statusCodeShouldMatchTheseRegularExpressions(int $statusCode, TableNode $table):void { + public function statusCodeShouldMatchTheseRegularExpressions(int $statusCode, TableNode $table): void { $actualStatusCode = $this->response->getStatusCode(); if ($actualStatusCode === $statusCode) { $this->headersShouldMatchRegularExpressions($table); @@ -3376,7 +3433,7 @@ public function statusCodeShouldMatchTheseRegularExpressions(int $statusCode, Ta * @return void * @throws Exception */ - public function headersShouldMatchRegularExpressionsForUser(string $user, TableNode $table):void { + public function headersShouldMatchRegularExpressionsForUser(string $user, TableNode $table): void { $this->verifyTableNodeColumnsCount($table, 2); $user = $this->getActualUsername($user); foreach ($table->getTable() as $header) { @@ -3409,7 +3466,7 @@ public function headersShouldMatchRegularExpressionsForUser(string $user, TableN public function userDeletesEverythingInFolder( string $user, string $folder - ):void { + ): void { $this->deleteEverythingInFolder($user, $folder, false); } @@ -3425,7 +3482,7 @@ public function deleteEverythingInFolder( string $user, string $folder, bool $checkEachDelete = false - ):void { + ): void { $user = $this->getActualUsername($user); $responseXmlObject = HttpRequestHelper::getResponseXml( $this->listFolder( @@ -3467,7 +3524,7 @@ public function deleteEverythingInFolder( * * @return void */ - public function downloadPreviewOfFiles(string $user, string $path, string $width, string $height):void { + public function downloadPreviewOfFiles(string $user, string $path, string $width, string $height): void { $response = $this->downloadPreviews( $user, $path, @@ -3488,7 +3545,12 @@ public function downloadPreviewOfFiles(string $user, string $path, string $width * * @return void */ - public function userDownloadsThePreviewOfWithPreviewZero(string $user, string $path, string $width, string $height) { + public function userDownloadsThePreviewOfWithPreviewZero( + string $user, + string $path, + string $width, + string $height + ) { $user = $this->getActualUsername($user); $urlParameter = [ 'x' => $width, @@ -3521,7 +3583,12 @@ public function userDownloadsThePreviewOfWithPreviewZero(string $user, string $p * * @return void */ - public function userDownloadsThePreviewOfSharedResourceWithWidthAndHeightUsingTheWebdavApi(string $user, string $path, string $width, string $height): void { + public function userDownloadsThePreviewOfSharedResourceWithWidthAndHeightUsingTheWebdavApi( + string $user, + string $path, + string $width, + string $height + ): void { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { $this->setResponse($this->downloadSharedFilePreview($user, $path, $width, $height)); } else { @@ -3540,7 +3607,13 @@ public function userDownloadsThePreviewOfSharedResourceWithWidthAndHeightUsingTh * * @return void */ - public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI(string $user, string $path, string $width, string $height, string $processor): void { + public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI( + string $user, + string $path, + string $width, + string $height, + string $processor + ): void { $user = $this->getActualUsername($user); $urlParameter = [ 'x' => $width, @@ -3574,7 +3647,12 @@ public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI( * * @return void */ - public function userDownloadsThePreviewOfFederatedShareImageWithWidthHeightUsingWebDAVAPI(string $user, string $path, string $width, string $height): void { + public function userDownloadsThePreviewOfFederatedShareImageWithWidthHeightUsingWebDAVAPI( + string $user, + string $path, + string $width, + string $height + ): void { $user = $this->getActualUsername($user); $urlParameter = [ 'x' => $width, @@ -3609,7 +3687,12 @@ public function userDownloadsThePreviewOfFederatedShareImageWithWidthHeightUsing * * @return void */ - public function userHasDownloadedThePreviewOfSharedResourceWithWidthAndHeight(string $user, string $path, string $width, string $height): void { + public function userHasDownloadedThePreviewOfSharedResourceWithWidthAndHeight( + string $user, + string $path, + string $width, + string $height + ): void { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { $response = $this->downloadSharedFilePreview($user, $path, $width, $height); } else { @@ -3633,7 +3716,12 @@ public function userHasDownloadedThePreviewOfSharedResourceWithWidthAndHeight(st * * @return void */ - public function asUserThePreviewOfSharedResourceWithWidthAndHeightShouldHaveBeenChanged(string $user, string $path, string $width, string $height):void { + public function asUserThePreviewOfSharedResourceWithWidthAndHeightShouldHaveBeenChanged( + string $user, + string $path, + string $width, + string $height + ): void { if ($this->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { $response = $this->downloadSharedFilePreview($user, $path, $width, $height); } else { @@ -3662,7 +3750,11 @@ public function asUserThePreviewOfSharedResourceWithWidthAndHeightShouldHaveBeen * * @return void */ - public function userUploadsFileWithContentSharedResourceToUsingTheWebdavApi(string $user, string $content, string $destination): void { + public function userUploadsFileWithContentSharedResourceToUsingTheWebdavApi( + string $user, + string $content, + string $destination + ): void { $this->setResponse($this->uploadFileWithContent($user, $content, $destination)); } @@ -3754,7 +3846,13 @@ public function downloadSharedFilePreview( * * @return void */ - public function downloadPreviewOfOtherUser(string $user, string $path, string $ofUser, string $width, string $height):void { + public function downloadPreviewOfOtherUser( + string $user, + string $path, + string $ofUser, + string $width, + string $height + ): void { $response = $this->downloadPreviews( $ofUser, $path, @@ -3784,7 +3882,7 @@ public function imageDimensionsShouldBe(string $width, string $height): void { * * @return void */ - public function checkImageDimensions(string $width, string $height, ?ResponseInterface $response = null) : void { + public function checkImageDimensions(string $width, string $height, ?ResponseInterface $response = null): void { $response = $response ?? $this->getResponse(); $response->getBody()->rewind(); $responseBodyContent = $response->getBody()->getContents(); @@ -3802,7 +3900,7 @@ public function checkImageDimensions(string $width, string $height, ?ResponseInt * @return void * @throws Exception */ - public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename):void { + public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename): void { $expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename); $this->getResponse()->getBody()->rewind(); $responseBodyContent = $this->getResponse()->getBody()->getContents(); @@ -3819,7 +3917,12 @@ public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContent * * @return void */ - public function userDownloadsThePreviewOfWithWidthAndHeight(string $user, string $path, string $width, string $height):void { + public function userDownloadsThePreviewOfWithWidthAndHeight( + string $user, + string $path, + string $width, + string $height + ): void { $response = $this->downloadPreviews( $user, $path, @@ -3844,7 +3947,12 @@ public function userDownloadsThePreviewOfWithWidthAndHeight(string $user, string * * @return void */ - public function asUserThePreviewOfPathWithHeightAndWidthShouldHaveBeenChanged(string $user, string $path, string $width, string $height):void { + public function asUserThePreviewOfPathWithHeightAndWidthShouldHaveBeenChanged( + string $user, + string $path, + string $width, + string $height + ): void { $response = $this->downloadPreviews( $user, $path, @@ -3897,7 +4005,7 @@ public function getFileIdForPath(string $user, string $path, string $spaceId = n * * @return void */ - public function userStoresFileIdForPath(string $user, string $path):void { + public function userStoresFileIdForPath(string $user, string $path): void { $this->storedFileID = $this->getFileIdForPath($user, $path); } @@ -3910,14 +4018,15 @@ public function userStoresFileIdForPath(string $user, string $path):void { * * @return void */ - public function userFileShouldHaveStoredId(string $user, string $fileOrFolder, string $path):void { + public function userFileShouldHaveStoredId(string $user, string $fileOrFolder, string $path): void { $user = $this->getActualUsername($user); $currentFileID = $this->getFileIdForPath($user, $path); Assert::assertEquals( $currentFileID, $this->storedFileID, __METHOD__ - . " User '$user' $fileOrFolder '$path' does not have the previously stored id '$this->storedFileID', but has '$currentFileID'." + . " User '$user' $fileOrFolder '$path' does not have the previously stored id " . + "'$this->storedFileID', but has '$currentFileID'." ); } @@ -3930,7 +4039,7 @@ public function userFileShouldHaveStoredId(string $user, string $fileOrFolder, s * @return void * @throws Exception */ - public function theDavElementShouldBe(string $element, string $message):void { + public function theDavElementShouldBe(string $element, string $message): void { $responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->getResponse()); WebDavAssert::assertDavResponseElementIs( $element, @@ -3958,7 +4067,7 @@ public function propfindResultShouldContainEntries( ?string $method = 'REPORT', ?string $folderpath = '', ?string $spaceId = null - ):void { + ): void { $folderpath = \trim($folderpath, "/"); $this->verifyTableNodeColumnsCount($expectedFiles, 1); $elementRows = $expectedFiles->getRows(); @@ -4015,7 +4124,7 @@ public function thePropfindResultShouldContainEntries( string $user, string $shouldOrNot, TableNode $expectedFiles - ):void { + ): void { $user = $this->getActualUsername($user); $this->propfindResultShouldContainEntries( $shouldOrNot, @@ -4036,7 +4145,7 @@ public function thePropfindResultShouldContainEntries( public function thePropfindResultShouldContainOnlyEntries( string $user, TableNode $expectedFiles - ):void { + ): void { $user = $this->getActualUsername($user); Assert::assertEquals( @@ -4060,7 +4169,7 @@ public function thePropfindResultShouldContainOnlyEntries( * * @return void */ - public function propfindResultShouldContainNumEntries(int $numFiles):void { + public function propfindResultShouldContainNumEntries(int $numFiles): void { $this->checkIFResponseContainsNumberEntries($numFiles); } @@ -4069,7 +4178,7 @@ public function propfindResultShouldContainNumEntries(int $numFiles):void { * * @return void */ - public function checkIFResponseContainsNumberEntries(int $numFiles):void { + public function checkIFResponseContainsNumberEntries(int $numFiles): void { $responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->response); Assert::assertIsArray( @@ -4109,7 +4218,7 @@ public function checkIFResponseContainsNumberEntries(int $numFiles):void { public function theSearchResultShouldContainAnyOfTheseEntries( int $expectedNumber, TableNode $expectedFiles - ):void { + ): void { $this->checkIfSearchResultContainsFiles( $this->getCurrentUser(), $expectedNumber, @@ -4131,7 +4240,7 @@ public function theSearchResultOfUserShouldContainAnyOfTheseEntries( string $user, int $expectedNumber, TableNode $expectedFiles - ):void { + ): void { $this->checkIfSearchResultContainsFiles( $user, $expectedNumber, @@ -4150,7 +4259,7 @@ public function checkIfSearchResultContainsFiles( string $user, int $expectedNumber, TableNode $expectedFiles - ):void { + ): void { $user = $this->getActualUsername($user); $this->verifyTableNodeColumnsCount($expectedFiles, 1); $this->checkIFResponseContainsNumberEntries($expectedNumber); @@ -4180,7 +4289,11 @@ function ($value) { * @return void * @throws Exception */ - public function userListsTheResourcesInPathWithDepthUsingTheWebdavApi(string $user, string $path, string $depth):void { + public function userListsTheResourcesInPathWithDepthUsingTheWebdavApi( + string $user, + string $path, + string $depth + ): void { $response = $this->listFolder( $user, $path, @@ -4198,7 +4311,7 @@ public function userListsTheResourcesInPathWithDepthUsingTheWebdavApi(string $us * @return void * @throws Exception */ - public function theLastDavResponseShouldContainTheseNodes(string $user, TableNode $table):void { + public function theLastDavResponseShouldContainTheseNodes(string $user, TableNode $table): void { $this->verifyTableNodeColumns($table, ["name"]); foreach ($table->getHash() as $row) { $path = $this->substituteInLineCodes($row['name']); @@ -4216,7 +4329,7 @@ public function theLastDavResponseShouldContainTheseNodes(string $user, TableNod * @return void * @throws Exception */ - public function theLastDavResponseShouldNotContainTheseNodes(string $user, TableNode $table):void { + public function theLastDavResponseShouldNotContainTheseNodes(string $user, TableNode $table): void { $this->verifyTableNodeColumns($table, ["name"]); foreach ($table->getHash() as $row) { $path = $this->substituteInLineCodes($row['name']); @@ -4233,8 +4346,9 @@ public function theLastDavResponseShouldNotContainTheseNodes(string $user, Table * @return void * @throws Exception */ - public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table):void { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table): void { + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $this->verifyTableNodeColumns($table, ["name"]); foreach ($table->getHash() as $row) { @@ -4252,8 +4366,9 @@ public function theLastPublicDavResponseShouldContainTheseNodes(TableNode $table * @return void * @throws Exception */ - public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table):void { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $table): void { + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $this->verifyTableNodeColumns($table, ["name"]); foreach ($table->getHash() as $row) { @@ -4271,8 +4386,11 @@ public function theLastPublicDavResponseShouldNotContainTheseNodes(TableNode $ta * @return void * @throws Exception */ - public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi(string $depth):void { - $token = ($this->isUsingSharingNG()) ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); + public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsingTheWebdavApi( + string $depth + ): void { + $token = ($this->isUsingSharingNG()) + ? $this->shareNgGetLastCreatedLinkShareToken() : $this->getLastCreatedPublicShareToken(); $this->setResponse( $this->listFolder( $token, @@ -4290,7 +4408,7 @@ public function thePublicListsTheResourcesInTheLastCreatedPublicLinkWithDepthUsi * * @return array */ - public function findEntryFromReportResponse(?string $user):array { + public function findEntryFromReportResponse(?string $user): array { $responseXmlObj = HttpRequestHelper::getResponseXml($this->getResponse()); $responseResources = []; $hrefs = $responseXmlObj->xpath('//d:href'); @@ -4316,7 +4434,7 @@ public function findEntryFromReportResponse(?string $user):array { */ public function getNumberOfEntriesInPropfindResponse( ?string $user = null - ):int { + ): int { $multistatusResults = $this->getMultiStatusResultFromPropfindResult($user); return \count($multistatusResults); } @@ -4331,7 +4449,7 @@ public function getNumberOfEntriesInPropfindResponse( */ public function getMultiStatusResultFromPropfindResult( ?string $user = null - ):array { + ): array { $responseXmlArray = HttpRequestHelper::parseResponseAsXml($this->response); Assert::assertNotEmpty($responseXmlArray, __METHOD__ . ' Response is empty'); @@ -4526,7 +4644,7 @@ public function findEntryFromSearchResponse( * * @return void */ - public function pauseUploadDelete():void { + public function pauseUploadDelete(): void { $time = \time(); $uploadWaitTime = \getenv("UPLOAD_DELETE_WAIT_TIME"); @@ -4546,7 +4664,7 @@ public function pauseUploadDelete():void { * * @return void */ - public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsername):void { + public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsername): void { $expectedUserDisplayName = $this->getUserDisplayName($expectedUsername); $responseXmlObject = HttpRequestHelper::getResponseXml( $this->getResponse(), @@ -4565,14 +4683,16 @@ public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsern } if (!isset($authors[$index - 1])) { Assert::fail( - 'could not find version with index "' . $index . '" for oc:meta-version-edited-by property in response to user "' . $this->responseUser . '"' + 'could not find version with index "' . $index + . '" for oc:meta-version-edited-by property in response to user "' . $this->responseUser . '"' ); } $actualUser = $authors[$index - 1]; Assert::assertEquals( $expectedUsername, $actualUser, - "Expected user of version with index $index in response to user '$this->responseUser' was '$expectedUsername', but got '$actualUser'" + "Expected user of version with index $index in response to user '$this->responseUser'" + . " was '$expectedUsername', but got '$actualUser'" ); // the user's display name should be in oc:meta-version-edited-by-name @@ -4587,14 +4707,16 @@ public function checkAuthorOfAVersionOfFile(string $index, string $expectedUsern } if (!isset($displaynames[$index - 1])) { Assert::fail( - 'could not find version with index "' . $index . '" for oc:meta-version-edited-by-name property in response to user "' . $this->responseUser . '"' + 'could not find version with index "' . $index + . '" for oc:meta-version-edited-by-name property in response to user "' . $this->responseUser . '"' ); } $actualUserDisplayName = $displaynames[$index - 1]; Assert::assertEquals( $expectedUserDisplayName, $actualUserDisplayName, - "Expected display name of version with index $index in response to user '$this->responseUser' was '$expectedUserDisplayName', but got '$actualUserDisplayName'" + "Expected display name of version with index $index in response to user '$this->responseUser'" + . " was '$expectedUserDisplayName', but got '$actualUserDisplayName'" ); } diff --git a/tests/acceptance/bootstrap/WebDavLockingContext.php b/tests/acceptance/bootstrap/WebDavLockingContext.php index 01c20c74029..431102095b6 100644 --- a/tests/acceptance/bootstrap/WebDavLockingContext.php +++ b/tests/acceptance/bootstrap/WebDavLockingContext.php @@ -69,7 +69,7 @@ private function lockFile( bool $public = false, bool $expectToSucceed = true, ?string $spaceId = null - ):ResponseInterface { + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); if ($public === true) { $type = "public-files"; @@ -146,7 +146,9 @@ private function lockFile( */ public function userLocksFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) { $spaceId = null; - if (\str_starts_with($file, "Shares/") && $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES) { + if (\str_starts_with($file, "Shares/") + && $this->featureContext->getDavPathVersion() === WebDavHelper::DAV_VERSION_SPACES + ) { $spaceId = $this->spacesContext->getSpaceIdByName($user, "Shares"); $file = \str_replace("Shares/", "", $file); } @@ -163,7 +165,11 @@ public function userLocksFileSettingPropertiesUsingWebDavAPI(string $user, strin * * @return void */ - public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(string $user, string $file, TableNode $properties) { + public function userTriesToLockFileSettingPropertiesUsingWebDavAPI( + string $user, + string $file, + TableNode $properties + ) { $response = $this->lockFile($user, $file, $properties, null, false, false); $this->featureContext->setResponse($response); } @@ -179,7 +185,12 @@ public function userTriesToLockFileSettingPropertiesUsingWebDavAPI(string $user, * @return void * @throws GuzzleException */ - public function userLocksFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) { + public function userLocksFileInProjectSpaceUsingWebDavAPI( + string $user, + string $file, + string $space, + TableNode $properties + ) { $this->featureContext->setResponse($this->userLocksFileInProjectSpace($user, $file, $space, $properties)); } @@ -193,7 +204,12 @@ public function userLocksFileInProjectSpaceUsingWebDavAPI(string $user, string $ * * @throws GuzzleException */ - public function userLocksFileInProjectSpace(string $user, string $file, string $space, TableNode $properties): ?ResponseInterface { + public function userLocksFileInProjectSpace( + string $user, + string $file, + string $space, + TableNode $properties + ): ?ResponseInterface { $spaceId = $this->spacesContext->getSpaceIdByName($user, $space); $baseUrl = $this->featureContext->getBaseUrl(); $davPathVersion = $this->featureContext->getDavPathVersion(); @@ -218,7 +234,12 @@ public function userLocksFileInProjectSpace(string $user, string $file, string $ * @return void * @throws GuzzleException */ - public function userHasLockedFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties): void { + public function userHasLockedFileInProjectSpaceUsingWebDavAPI( + string $user, + string $file, + string $space, + TableNode $properties + ): void { $response = $this->userLocksFileInProjectSpace($user, $file, $space, $properties); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); } @@ -233,7 +254,12 @@ public function userHasLockedFileInProjectSpaceUsingWebDavAPI(string $user, stri * * @return void */ - public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, string $file, string $space, TableNode $properties) { + public function userTriesToLockFileInProjectSpaceUsingWebDavAPI( + string $user, + string $file, + string $space, + TableNode $properties + ) { $spaceId = $this->spacesContext->getSpaceIdByName($user, $space); $davPathVersion = $this->featureContext->getDavPathVersion(); $suffixPath = $user; @@ -257,7 +283,12 @@ public function userTriesToLockFileInProjectSpaceUsingWebDavAPI(string $user, st * * @return void */ - public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties(string $user, string $file, string $fileId, TableNode $properties) { + public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties( + string $user, + string $file, + string $fileId, + TableNode $properties + ) { $davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = \rtrim($davPath, '/'); $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; @@ -275,7 +306,12 @@ public function userLocksFileUsingFileIdUsingWebDavAPISettingFollowingProperties * * @return void */ - public function userTriesToLockFileUsingFileIdUsingWebDavAPI(string $user, string $file, string $fileId, TableNode $properties) { + public function userTriesToLockFileUsingFileIdUsingWebDavAPI( + string $user, + string $file, + string $fileId, + TableNode $properties + ) { $davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = \rtrim($davPath, '/'); $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; @@ -307,7 +343,12 @@ public function userHasLockedFile(string $user, string $file, TableNode $propert * * @return void */ - public function userHasLockedFileInsideSpaceSettingTheFollowingProperties(string $user, string $file, string $spaceName, TableNode $properties) { + public function userHasLockedFileInsideSpaceSettingTheFollowingProperties( + string $user, + string $file, + string $spaceName, + TableNode $properties + ) { $spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName); $response = $this->lockFile($user, $file, $properties, null, false, true, $spaceId); $this->featureContext->theHTTPStatusCodeShouldBe(200, '', $response); @@ -358,7 +399,9 @@ public function publicHasLockedLastSharedFile(TableNode $properties) { * @return void */ public function publicLocksLastSharedFile(TableNode $properties) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $response = $this->lockFile( $token, "/", @@ -382,7 +425,9 @@ public function publicHasLockedFileLastSharedFolder( string $file, TableNode $properties ) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $response = $this->lockFile( $token, $file, @@ -406,7 +451,9 @@ public function publicLocksFileLastSharedFolder( string $file, TableNode $properties ) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $response = $this->lockFile( $token, $file, @@ -445,7 +492,11 @@ public function unlockLastLockUsingWebDavAPI(string $user, string $file) { * * @return void */ - public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi(string $user, string $spaceName, string $file) { + public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi( + string $user, + string $spaceName, + string $file + ) { $spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getActualUsername($user), $spaceName); $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $user, @@ -468,11 +519,22 @@ public function userUnlocksTheLastCreatedLockOfFileInsideSpaceUsingTheWebdavApi( * * @return void */ - public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi(string $user, string $itemToUnlock, string $fileId) { + public function userUnlocksTheLastCreatedLockOfFileWithFileIdPathUsingTheWebdavApi( + string $user, + string $itemToUnlock, + string $fileId + ) { $davPath = WebdavHelper::getDavPath($this->featureContext->getDavPathVersion()); $davPath = \rtrim($davPath, '/'); $fullUrl = $this->featureContext->getBaseUrl() . "/$davPath/$fileId"; - $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI($user, $itemToUnlock, $user, $itemToUnlock, false, $fullUrl); + $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( + $user, + $itemToUnlock, + $user, + $itemToUnlock, + false, + $fullUrl + ); $this->featureContext->setResponse($response); } @@ -535,7 +597,7 @@ public function unlockItemWithLastPublicLockOfOtherItemUsingWebDavAPI( private function countLockOfResources( string $user, string $itemToUnlock - ):int { + ): int { $user = $this->featureContext->getActualUsername($user); $baseUrl = $this->featureContext->getBaseUrl(); $password = $this->featureContext->getPasswordForUser($user); @@ -625,7 +687,7 @@ public function unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( bool $public = false, string $fullUrl = null, ?string $spaceId = null, - ):ResponseInterface { + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $lockOwner = $this->featureContext->getActualUsername($lockOwner); if ($public === true) { @@ -711,7 +773,9 @@ public function unlockItemAsPublicWithLastLockOfUserAndItemUsingWebDavAPI( string $lockOwner, string $itemToUseLockOf ) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $token, $itemToUnlock, @@ -730,7 +794,9 @@ public function unlockItemAsPublicWithLastLockOfUserAndItemUsingWebDavAPI( * @return void */ public function unlockItemAsPublicUsingWebDavAPI(string $itemToUnlock) { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $response = $this->unlockItemWithLastLockOfUserAndItemUsingWebDavAPI( $token, $itemToUnlock, @@ -782,7 +848,7 @@ public function moveItemSendingLockTokenOfUser( string $fileDestination, string $itemToUseLockOf, string $lockOwner - ):ResponseInterface { + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); $lockOwner = $this->featureContext->getActualUsername($lockOwner); $destination = $this->featureContext->destinationHeaderValue( @@ -901,7 +967,12 @@ public function waitForCertainSecondsToExpireTheLock(int $time): void { * @return void * @throws GuzzleException */ - public function numberOfLockShouldBeReportedInProjectSpace(int $count, string $file, string $spaceName, string $user) { + public function numberOfLockShouldBeReportedInProjectSpace( + int $count, + string $file, + string $spaceName, + string $user + ) { $response = $this->spacesContext->sendPropfindRequestToSpace($user, $spaceName, $file, null, '0'); $this->featureContext->theHTTPStatusCodeShouldBe(207, "", $response); $responseXmlObject = HttpRequestHelper::getResponseXml($response, __METHOD__); diff --git a/tests/acceptance/bootstrap/WebDavPropertiesContext.php b/tests/acceptance/bootstrap/WebDavPropertiesContext.php index bb2cd9d5a4b..ac369e36425 100644 --- a/tests/acceptance/bootstrap/WebDavPropertiesContext.php +++ b/tests/acceptance/bootstrap/WebDavPropertiesContext.php @@ -56,7 +56,7 @@ class WebDavPropertiesContext implements Context { public function userGetsThePropertiesOfFolder( string $user, string $path - ):void { + ): void { $response = $this->featureContext->listFolder( $user, $path, @@ -79,7 +79,7 @@ public function userGetsThePropertiesOfFolderWithDepth( string $user, string $path, string $depth - ):void { + ): void { $response = $this->featureContext->listFolder( $user, $path, @@ -133,7 +133,7 @@ public function userGetsFollowingPropertiesOfEntryUsingWebDavApi( string $user, string $path, TableNode $propertiesTable - ):void { + ): void { $response = $this->getPropertiesOfFolder($user, $path, null, $propertiesTable); $this->featureContext->setResponse($response); $this->featureContext->pushToLastStatusCodesArrays(); @@ -170,7 +170,11 @@ public function theUserGetsPropertiesOfFolder(string $path, TableNode $propertie * @return void * @throws Exception */ - public function userHasSetFollowingPropertiesUsingProppatch(string $username, string $path, TableNode $propertiesTable) { + public function userHasSetFollowingPropertiesUsingProppatch( + string $username, + string $path, + TableNode $propertiesTable + ) { $username = $this->featureContext->getActualUsername($username); $this->featureContext->verifyTableNodeColumns($propertiesTable, ['propertyName', 'propertyValue']); $properties = $propertiesTable->getColumnsHash(); @@ -200,7 +204,7 @@ public function userGetsCustomPropertyOfFile( string $user, string $propertyName, string $path - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $properties = [$propertyName]; $response = WebDavHelper::propfind( @@ -234,7 +238,7 @@ public function userGetsPropertiesWithNamespaceOfFile( string $propertyName, string $namespace, string $path - ):void { + ): void { $user = $this->featureContext->getActualUsername($user); $properties = [ $namespace => $propertyName @@ -262,7 +266,9 @@ public function userGetsPropertiesWithNamespaceOfFile( * @throws Exception */ public function getPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable): ResponseInterface { - $token = ($this->featureContext->isUsingSharingNG()) ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() : $this->featureContext->getLastCreatedPublicShareToken(); + $token = ($this->featureContext->isUsingSharingNG()) + ? $this->featureContext->shareNgGetLastCreatedLinkShareToken() + : $this->featureContext->getLastCreatedPublicShareToken(); $properties = null; foreach ($propertiesTable->getRows() as $row) { $properties[] = $row[0]; @@ -286,7 +292,10 @@ public function getPropertiesOfEntryFromLastLinkShare(string $path, TableNode $p * @return void * @throws Exception */ - public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare(string $path, TableNode $propertiesTable):void { + public function thePublicGetsFollowingPropertiesOfEntryFromLastLinkShare( + string $path, + TableNode $propertiesTable + ): void { $response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable); $this->featureContext->setResponse($response); } @@ -307,7 +316,7 @@ public function setResourceProperty( string $path, string $propertyValue, string $namespace = null, - ):ResponseInterface { + ): ResponseInterface { $user = $this->featureContext->getActualUsername($user); return WebDavHelper::proppatch( $this->featureContext->getBaseUrl(), @@ -338,7 +347,7 @@ public function userSetsPropertyOfEntryTo( string $propertyName, string $path, string $propertyValue - ):void { + ): void { $response = $this->setResourceProperty( $user, $propertyName, @@ -366,7 +375,7 @@ public function userSetsPropertyWithNamespaceOfEntryTo( string $namespace, string $path, string $propertyValue - ):void { + ): void { $response = $this->setResourceProperty( $user, $propertyName, @@ -393,7 +402,7 @@ public function userHasSetPropertyOfEntryTo( string $propertyName, string $path, string $propertyValue - ):void { + ): void { $response = $this->setResourceProperty( $user, $propertyName, @@ -421,7 +430,7 @@ public function userHasSetPropertyWithNamespaceOfEntryTo( string $namespace, string $path, string $propertyValue - ):void { + ): void { $response = $this->setResourceProperty( $user, $propertyName, @@ -477,7 +486,7 @@ public function theResponseShouldContainACustomPropertyWithNamespaceAndValue( string $propertyName, string $namespaceString, string $propertyValue - ):void { + ): void { // let's unescape quotes first $propertyValue = \str_replace('\"', '"', $propertyValue); $responseXmlObject = HttpRequestHelper::getResponseXml( @@ -518,7 +527,7 @@ public function theResponseShouldContainACustomPropertyWithNamespaceAndValue( public function theSingleResponseShouldContainAPropertyWithChildProperty( string $property, string $childProperty - ):void { + ): void { $xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath( "//d:prop/$property/$childProperty" ); @@ -572,7 +581,7 @@ public function theResponseShouldContainPropertyWithNamespace(string $key, strin public function theSingleResponseShouldContainAPropertyWithValue( string $key, string $expectedValue - ):void { + ): void { $this->checkResponseContainsAPropertyWithValue( $this->featureContext->getResponse(), $key, @@ -595,7 +604,7 @@ public function theSingleResponseAboutTheFileOwnedByShouldContainAPropertyWithVa string $user, string $key, string $expectedValue - ):void { + ): void { $this->checkResponseContainsAPropertyWithValue( $this->featureContext->getResponse(), $key, @@ -619,7 +628,7 @@ public function theSingleResponseShouldContainAPropertyWithValueAndAlternative( string $key, string $expectedValue, string $altExpectedValue - ):void { + ): void { $this->checkResponseContainsAPropertyWithValue( $this->featureContext->getResponse(), $key, @@ -636,7 +645,11 @@ public function theSingleResponseShouldContainAPropertyWithValueAndAlternative( * @return SimpleXMLElement * @throws Exception */ - public function checkResponseContainsProperty(ResponseInterface $response, string $key, string $namespaceString = null): SimpleXMLElement { + public function checkResponseContainsProperty( + ResponseInterface $response, + string $key, + string $namespaceString = null + ): SimpleXMLElement { $xmlPart = HttpRequestHelper::getResponseXml($response, __METHOD__); ; @@ -680,7 +693,7 @@ public function checkResponseContainsAPropertyWithValue( string $expectedValue, string $altExpectedValue, ?string $user = null - ):void { + ): void { $xmlPart = $this->checkResponseContainsProperty($response, $key); $value = $xmlPart->__toString(); $expectedValue = $this->featureContext->substituteInLineCodes( @@ -708,7 +721,7 @@ public function checkResponseContainsAPropertyWithValue( * @return void * @throws Exception */ - public function assertValueOfItemInResponseIs(string $xpath, string $expectedValue):void { + public function assertValueOfItemInResponseIs(string $xpath, string $expectedValue): void { $this->assertValueOfItemInResponseAboutUserIs( $xpath, null, @@ -727,7 +740,7 @@ public function assertValueOfItemInResponseIs(string $xpath, string $expectedVal * @return void * @throws Exception */ - public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue):void { + public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $path, string $expectedValue): void { $path = $this->featureContext->substituteInLineCodes($path, $user); $path = \ltrim($path, '/'); $path = "/" . WebdavHelper::prefixRemotePhp($path); @@ -749,7 +762,11 @@ public function valueOfItemOfPathShouldBe(string $user, string $xpath, string $p * @return void * @throws Exception */ - public function theValueOfTheItemInTheResponseAboutUserShouldBe(string $xpath, string $user, string $expectedValue):void { + public function theValueOfTheItemInTheResponseAboutUserShouldBe( + string $xpath, + string $user, + string $expectedValue + ): void { $this->assertValueOfItemInResponseAboutUserIs($xpath, $user, $expectedValue); } @@ -760,7 +777,7 @@ public function theValueOfTheItemInTheResponseAboutUserShouldBe(string $xpath, s * * @return void */ - public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue):void { + public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $user, string $expectedValue): void { $responseXmlObject = HttpRequestHelper::getResponseXml( $this->featureContext->getResponse(), __METHOD__ @@ -794,7 +811,12 @@ public function assertValueOfItemInResponseAboutUserIs(string $xpath, ?string $u * @return void * @throws Exception */ - public function assertValueOfItemInResponseAboutUserIsEitherOr(string $xpath, ?string $user, string $expectedValue1, string $expectedValue2):void { + public function assertValueOfItemInResponseAboutUserIsEitherOr( + string $xpath, + ?string $user, + string $expectedValue1, + string $expectedValue2 + ): void { if (!$expectedValue2) { $expectedValue2 = $expectedValue1; } @@ -820,7 +842,10 @@ public function assertValueOfItemInResponseAboutUserIsEitherOr(string $xpath, ?s $expectedValue2 = preg_replace("/^\/\//i", "/", $expectedValue2); $expectedValues = [$expectedValue1, $expectedValue2]; $isExpectedValueInMessage = \in_array($value, $expectedValues); - Assert::assertTrue($isExpectedValueInMessage, "The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\""); + Assert::assertTrue( + $isExpectedValueInMessage, + "The actual value \"$value\" is not one of the expected values: \"$expectedValue1\" or \"$expectedValue2\"" + ); } /** @@ -850,7 +875,7 @@ public function getXmlItemByXpath( * @return void * @throws Exception */ - public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern):void { + public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern): void { $this->assertXpathValueMatchesPattern( HttpRequestHelper::getResponseXml($this->featureContext->getResponse()), $xpath, @@ -868,7 +893,11 @@ public function assertValueOfItemInResponseRegExp(string $xpath, string $pattern * @return void * @throws Exception */ - public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp(string $xpath, string $path, string $pattern):void { + public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseRegExp( + string $xpath, + string $path, + string $pattern + ): void { $propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]); $response = $this->getPropertiesOfEntryFromLastLinkShare($path, $propertiesTable); $this->featureContext->theHTTPStatusCodeShouldBe('207', "", $response); @@ -888,7 +917,7 @@ public function publicGetsThePropertiesOfFolderAndAssertValueOfItemInResponseReg * @return void * @throws Exception */ - public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user):void { + public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expectedHref, string $user): void { $responseXmlObject = HttpRequestHelper::getResponseXml( $this->featureContext->getResponse(), __METHOD__ @@ -947,7 +976,12 @@ public function assertEntryWithHrefMatchingRegExpInResponseToUser(string $expect * @return void * @throws JsonException */ - public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObject, string $xpath, string $pattern, ?string $user = null): void { + public function assertXpathValueMatchesPattern( + SimpleXMLElement $responseXmlObject, + string $xpath, + string $pattern, + ?string $user = null + ): void { $xmlPart = $responseXmlObject->xpath($xpath); Assert::assertTrue( isset($xmlPart[0]), @@ -955,7 +989,8 @@ public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObje ); $user = $this->featureContext->getActualUsername($user); $value = $xmlPart[0]->__toString(); - $callback = ($this->featureContext->isUsingSharingNG()) ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken"; + $callback = ($this->featureContext->isUsingSharingNG()) + ? "shareNgGetLastCreatedLinkShareToken" : "getLastCreatedPublicShareToken"; if (\str_ends_with($xpath, "d:href")) { $pattern = \preg_replace("/^\//", "", $pattern); @@ -996,7 +1031,12 @@ public function assertXpathValueMatchesPattern(SimpleXMLElement $responseXmlObje * @return void * @throws Exception */ - public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp(string $user, string $xpath, string $path, string $pattern):void { + public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRegExp( + string $user, + string $xpath, + string $path, + string $pattern + ): void { $propertiesTable = new TableNode([['propertyName'],['d:lockdiscovery']]); $response = $this->getPropertiesOfFolder( $user, @@ -1021,7 +1061,7 @@ public function userGetsPropertiesOfFolderAndAssertValueOfItemInResponseToUserRe * @return void * @throws Exception */ - public function assertItemInResponseDoesNotExist(string $xpath):void { + public function assertItemInResponseDoesNotExist(string $xpath): void { $xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath($xpath); Assert::assertFalse( isset($xmlPart[0]), @@ -1047,7 +1087,7 @@ public function asUserFolderShouldContainAPropertyWithValueOrWithValue( string $property, string $expectedValue, ?string $altExpectedValue = null - ):void { + ): void { $this->checkPropertyOfAFolder($user, $path, $property, $expectedValue, $altExpectedValue); } @@ -1068,7 +1108,7 @@ public function checkPropertyOfAFolder( string $expectedValue, ?string $altExpectedValue = null, ?string $spaceId = null, - ):void { + ): void { $response = $this->featureContext->listFolder( $user, $path, @@ -1099,7 +1139,7 @@ public function checkPropertyOfAFolder( public function theSingleResponseShouldContainAPropertyWithValueLike( string $key, string $regex - ):void { + ): void { $xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath( "//d:prop/$key" ); @@ -1123,7 +1163,7 @@ public function theSingleResponseShouldContainAPropertyWithValueLike( * @return void * @throws Exception */ - public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table):void { + public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table): void { $this->featureContext->verifyTableNodeColumnsCount($table, 1); WebdavTest::assertResponseContainsShareTypes( HttpRequestHelper::getResponseXml($this->featureContext->getResponse()), @@ -1139,7 +1179,7 @@ public function theResponseShouldContainAShareTypesPropertyWith(TableNode $table * @return void * @throws Exception */ - public function theResponseShouldContainAnEmptyProperty(string $property):void { + public function theResponseShouldContainAnEmptyProperty(string $property): void { $xmlPart = HttpRequestHelper::getResponseXml($this->featureContext->getResponse())->xpath( "//d:prop/$property" ); @@ -1163,7 +1203,12 @@ public function theResponseShouldContainAnEmptyProperty(string $property):void { * @return SimpleXMLElement * @throws Exception */ - public function storeEtagOfElement(string $user, string $path, ?string $storePath = "", ?string $spaceId = null):SimpleXMLElement { + public function storeEtagOfElement( + string $user, + string $path, + ?string $storePath = "", + ?string $spaceId = null + ): SimpleXMLElement { if ($storePath === "") { $storePath = $path; } @@ -1190,7 +1235,7 @@ public function storeEtagOfElement(string $user, string $path, ?string $storePat * @return void * @throws Exception */ - public function userStoresEtagOfElement(string $user, string $path):void { + public function userStoresEtagOfElement(string $user, string $path): void { $this->storeEtagOfElement( $user, $path @@ -1207,7 +1252,7 @@ public function userStoresEtagOfElement(string $user, string $path):void { * @return void * @throws Exception */ - public function userStoresEtagOfElementOnPath(string $user, string $path, string $storePath):void { + public function userStoresEtagOfElementOnPath(string $user, string $path, string $storePath): void { $user = $this->featureContext->getActualUsername($user); $this->storeEtagOfElement( $user, @@ -1231,7 +1276,7 @@ public function userStoresEtagOfElementOnPath(string $user, string $path, string * @return void * @throws Exception */ - public function userHasStoredEtagOfElement(string $user, string $path):void { + public function userHasStoredEtagOfElement(string $user, string $path): void { $user = $this->featureContext->getActualUsername($user); $this->storeEtagOfElement( $user, @@ -1248,7 +1293,7 @@ public function userHasStoredEtagOfElement(string $user, string $path):void { * @return void * @throws Exception */ - public function thePropertiesResponseShouldContainAnEtag():void { + public function thePropertiesResponseShouldContainAnEtag(): void { Assert::assertTrue( $this->featureContext->isEtagValid($this->featureContext->getEtagFromResponseXmlObject()), __METHOD__ @@ -1287,8 +1332,11 @@ public function parseBaseDavPathFromXMLHref(string $href): string { * @return void * @throws Exception */ - public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable):void { - $this->featureContext->verifyTableNodeColumns($expectedPropTable, ['resource', 'propertyName', 'propertyValue']); + public function theResponseShouldHavePropertyWithValue(string $username, TableNode $expectedPropTable): void { + $this->featureContext->verifyTableNodeColumns( + $expectedPropTable, + ['resource', 'propertyName', 'propertyValue'] + ); $responseXmlObject = HttpRequestHelper::getResponseXml($this->featureContext->getResponse()); $href = (string)$responseXmlObject->xpath("//d:href")[0]; @@ -1315,7 +1363,7 @@ public function theResponseShouldHavePropertyWithValue(string $username, TableNo * @return string * @throws Exception */ - public function getCurrentEtagOfElement(string $path, string $user):string { + public function getCurrentEtagOfElement(string $path, string $user): string { $user = $this->featureContext->getActualUsername($user); $propertiesTable = new TableNode([['propertyName'],['d:getetag']]); $response = $this->getPropertiesOfFolder( @@ -1324,7 +1372,9 @@ public function getCurrentEtagOfElement(string $path, string $user):string { null, $propertiesTable ); - return $this->featureContext->getEtagFromResponseXmlObject(HttpRequestHelper::getResponseXml($response, __METHOD__)); + return $this->featureContext->getEtagFromResponseXmlObject( + HttpRequestHelper::getResponseXml($response, __METHOD__) + ); } /** @@ -1334,7 +1384,7 @@ public function getCurrentEtagOfElement(string $path, string $user):string { * * @return string */ - public function getStoredEtagOfElement(string $path, string $user, string $messageStart = ''):string { + public function getStoredEtagOfElement(string $path, string $user, string $messageStart = ''): string { if ($messageStart === '') { $messageStart = __METHOD__; } @@ -1348,7 +1398,8 @@ public function getStoredEtagOfElement(string $path, string $user, string $messa $path, $this->storedETAG[$user], $messageStart - . " Trying to check etag of element $path of user $user but the user does not have a stored etag for the element" + . " Trying to check etag of element $path of user " + . "$user but the user does not have a stored etag for the element" ); return $this->storedETAG[$user][$path]; } @@ -1361,7 +1412,7 @@ public function getStoredEtagOfElement(string $path, string $user, string $messa * @return void * @throws Exception */ - public function theseEtagsShouldNotHaveChanged(TableNode $etagTable):void { + public function theseEtagsShouldNotHaveChanged(TableNode $etagTable): void { $this->featureContext->verifyTableNodeColumns($etagTable, ["user", "path"]); $this->featureContext->verifyTableNodeColumnsCount($etagTable, 2); $changedEtagCount = 0; @@ -1389,7 +1440,7 @@ public function theseEtagsShouldNotHaveChanged(TableNode $etagTable):void { * @return void * @throws Exception */ - public function theseEtagsShouldHaveChanged(TableNode $etagTable):void { + public function theseEtagsShouldHaveChanged(TableNode $etagTable): void { $this->featureContext->verifyTableNodeColumns($etagTable, ["user", "path"]); $this->featureContext->verifyTableNodeColumnsCount($etagTable, 2); $unchangedEtagCount = 0; @@ -1419,7 +1470,11 @@ public function theseEtagsShouldHaveChanged(TableNode $etagTable):void { * @return void * @throws Exception */ - public function etagOfElementOfUserShouldOrShouldNotHaveChanged(string $path, string $user, string $shouldShouldNot):void { + public function etagOfElementOfUserShouldOrShouldNotHaveChanged( + string $path, + string $user, + string $shouldShouldNot + ): void { $user = $this->featureContext->getActualUsername($user); $actualEtag = $this->getCurrentEtagOfElement($path, $user); $storedEtag = $this->getStoredEtagOfElement($path, $user, __METHOD__); @@ -1452,7 +1507,7 @@ public function etagOfElementOfUserShouldOrShouldNotHaveChanged(string $path, st * * @return void */ - public function before(BeforeScenarioScope $scope):void { + public function before(BeforeScenarioScope $scope): void { // Get the environment $environment = $scope->getEnvironment(); // Get all the contexts you need in this context