From c3511c71ac42dca31cdfab68fd271e4f5c9e2ec2 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 29 Apr 2022 22:22:41 +0200 Subject: [PATCH] adapt spaces context --- .../features/bootstrap/SpacesContext.php | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index a31f5666b4..5f9c23357d 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -220,6 +220,24 @@ class SpacesContext implements Context { return $spaces[$spaceName]; } + /** + * The method finds available spaces to the manager user and returns the space by spaceName + * + * @param string $user + * @param string $spaceName + * + * @return array + */ + public function getSpaceByNameManager(string $user, string $spaceName): array { + $this->theUserListsAllAvailableSpacesUsingTheGraphApi($user); + + $spaces = $this->getAvailableSpaces(); + Assert::assertIsArray($spaces[$spaceName], "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]; + } + /** * The method finds file by fileName and spaceName and returns data of file wich contains in responseHeader * fileName contains the path, if the file is in the folder @@ -410,6 +428,33 @@ class SpacesContext implements Context { return HttpRequestHelper::get($fullUrl, $xRequestId, $user, $password, $headers, $body); } + /** + * Send Graph List All Spaces Request + * + * @param string $user + * @param string $password + * @param string $urlArguments + * @param string $xRequestId + * @param array $body + * @param array $headers + * + * @return ResponseInterface + * + * @throws GuzzleException + */ + public function listAllSpacesRequest( + string $user, + string $password, + string $urlArguments = '', + string $xRequestId = '', + array $body = [], + array $headers = [] + ): ResponseInterface { + $fullUrl = $this->baseUrl . "/graph/v1.0/drives/" . $urlArguments; + + return HttpRequestHelper::get($fullUrl, $xRequestId, $user, $password, $headers, $body); + } + /** * Send Graph List Single Space Request * @@ -530,6 +575,24 @@ class SpacesContext implements Context { $this->rememberTheAvailableSpaces(); } + /** + * + * @param string $user + * + * @return void + * + * @throws GuzzleException + */ + public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user): void { + $this->featureContext->setResponse( + $this->listAllSpacesRequest( + $user, + $this->featureContext->getPasswordForUser($user) + ) + ); + $this->rememberTheAvailableSpaces(); + } + /** * @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/ * @@ -1951,7 +2014,7 @@ class SpacesContext implements Context { string $userWithManagerRights = '' ): void { if (!empty($userWithManagerRights)) { - $space = $this->getSpaceByName($userWithManagerRights, $spaceName); + $space = $this->getSpaceByNameManager($userWithManagerRights, $spaceName); } else { $space = $this->getSpaceByName($user, $spaceName); }