From c80e773234ef4d662e16884253cd5953c5fe7098 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Wed, 30 Nov 2022 16:50:58 +0545 Subject: [PATCH] Added drive info check --- .../features/apiGraph/getUser.feature | 24 ++++++----------- .../features/bootstrap/GraphContext.php | 27 +++++++++++++++++++ .../features/bootstrap/SpacesContext.php | 3 +++ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/tests/acceptance/features/apiGraph/getUser.feature b/tests/acceptance/features/apiGraph/getUser.feature index 05df4502d9..cc21ad5090 100644 --- a/tests/acceptance/features/apiGraph/getUser.feature +++ b/tests/acceptance/features/apiGraph/getUser.feature @@ -60,14 +60,10 @@ Feature: get users And the user retrieve API response should contain the following information: | displayName | id | mail | onPremisesSamAccountName | | Brian Murphy | %uuid_v4% | brian@example.org | Brian | -# And the drive information of user "Brian" should contain: -# | key | value | -# | driveType | personal | -# | driveAlias | personal/alice | -# | id | %space_id% | -# | name | Brian Murphy | -# | quota@@@state | normal | -# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% | + And the response should contain the following drive information: + | driveType | personal | + | driveAlias | personal/brian | + | name | Brian Murphy | Scenario: normal user tries to get hid/her own drive information @@ -79,11 +75,7 @@ Feature: get users And the user retrieve API response should contain the following information: | displayName | id | mail | onPremisesSamAccountName | | Brian Murphy | %uuid_v4% | brian@example.org | Brian | -# And the drive information of user "Brian" should contain: -# | key | value | -# | driveType | personal | -# | driveAlias | personal/brian | -# | id | %space_id% | -# | name | Brian Murphy | -# | quota@@@state | normal | -# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% | + And the response should contain the following drive information: + | driveType | personal | + | driveAlias | personal/brian | + | name | Brian Murphy | diff --git a/tests/acceptance/features/bootstrap/GraphContext.php b/tests/acceptance/features/bootstrap/GraphContext.php index 2b2f251c64..6f33387364 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -28,6 +28,11 @@ class GraphContext implements Context { */ private FeatureContext $featureContext; + /** + * @var SpacesContext + */ + private SpacesContext $spacesContext; + /** * This will run before EVERY scenario. * It will set the properties for this object. @@ -43,6 +48,7 @@ class GraphContext implements Context { $environment = $scope->getEnvironment(); // Get all the contexts you need in this context from here $this->featureContext = $environment->getContext('FeatureContext'); + $this->spacesContext = $environment->getContext('SpacesContext'); } /** @@ -1357,4 +1363,25 @@ class GraphContext implements Context { $response = $this->retrieveUserInformationAlongWithDriveUsingGraphApi($user); $this->featureContext->setResponse($response); } + + + + /** + * @Then the response should contain the following drive information: + */ + public function theResponseShouldContainTheFollowingDriveInformation(TableNode $table) + { + $rows = $table->getRowsHash(); + $responseAPI = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['drive']; + foreach (array_keys($rows) as $keyName) { + Assert::assertEquals( + $rows[$keyName], + $responseAPI[$keyName], + __METHOD__ . + ' Expected ' . $keyName . 'to have value' . $responseAPI[$keyName] + . ' but got ' . $rows[$keyName] + ); + } + } + } diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index c0e7b23711..ba7e541313 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -913,6 +913,9 @@ class SpacesContext implements Context { foreach ($table->getHash() as $row) { // remember the original Space Array $original = $spaceAsArray; + var_dump( + $original + ); $row['value'] = $this->featureContext->substituteInLineCodes( $row['value'], $this->featureContext->getCurrentUser(),