From 46575abe11fba2faaa2d16566de3b202579e46c1 Mon Sep 17 00:00:00 2001 From: "sagargurung1001@gmail.com" Date: Wed, 7 Dec 2022 16:28:25 +0545 Subject: [PATCH] Drive infor assertion --- .../features/apiGraph/getUser.feature | 40 +++++++++------- .../features/bootstrap/GraphContext.php | 46 +++++++++++++------ 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/tests/acceptance/features/apiGraph/getUser.feature b/tests/acceptance/features/apiGraph/getUser.feature index cc21ad5090..8aa64d2b9f 100644 --- a/tests/acceptance/features/apiGraph/getUser.feature +++ b/tests/acceptance/features/apiGraph/getUser.feature @@ -60,22 +60,28 @@ 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 response should contain the following drive information: - | driveType | personal | - | driveAlias | personal/brian | - | name | Brian Murphy | + And the user retrieve API response should contain the following drive information: +# | driveType | personal | +# | driveAlias | personal/brian | +# | id | %space_id% | +# | name | Brian Murphy | + | owner@@@user@@@id | %user_id% | +# | quota@@@state | normal | +# | root@@@id | %space_id% | +# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% | +# | webUrl | %base_url%/f/%space_id% | - Scenario: normal user tries to get hid/her own drive information - Given these users have been created with default attributes and without skeleton files: - | username | - | Brian | - When the user "Brian" tries to get his drive information using Graph API - Then the HTTP status code should be "200" - 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 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 +# Given these users have been created with default attributes and without skeleton files: +# | username | +# | Brian | +# When the user "Brian" tries to get his drive information using Graph API +# Then the HTTP status code should be "200" +# 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 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 9fa1777fff..a37cc1642d 100644 --- a/tests/acceptance/features/bootstrap/GraphContext.php +++ b/tests/acceptance/features/bootstrap/GraphContext.php @@ -1364,23 +1364,43 @@ class GraphContext implements Context { } - /** - * @Then the response should contain the following drive information: + * @param array $expectedDriveInformation + * @param array $actualValueDriveInformation + * + * @throws GuzzleException + * @return void */ - 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] + public function checkUserDriveInformation(array $expectedDriveInformation, array $actualValueDriveInformation):void { + foreach (array_keys($expectedDriveInformation) as $keyName) { + // break the segment with @@@ here + $separatedKey = explode("@@@",$keyName); + $actualKeyAvalue = null; + $actualKeyAvalue = $actualValueDriveInformation['owner']; + var_dump( + $actualKeyAvalue + ); + foreach ($separatedKey as $key) { + // this loop sets and get the actual keyvalue from the actual API response + $actualKeyAvalue = $actualValueDriveInformation[$key]; + } + var_dump( + $actualKeyAvalue ); } } + + + /** + * @Then the user retrieve API response should contain the following drive information: + */ + public function theResponseShouldContainTheFollowingDriveInformation(TableNode $table) + { + $expectedDriveInformation = $table->getRowsHash(); + // array of user drive information (Personal Drive Information Only) + $actualDriveInformation = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['drive']; + $this->checkUserDriveInformation($expectedDriveInformation, $actualDriveInformation); + } + }