mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-05 19:09:56 -05:00
[tests-only] Added test for sharingNg for endpoint sharedByMe from personal space (#8285)
* Added tests to list shared by me resources Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * Review address --------- Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
@@ -2525,4 +2525,62 @@ class GraphContext implements Context {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user lists the resources shared by him/her using the Graph API
|
||||
*
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userListsTheResourcesSharedByAUserUsingGraphApi(string $user): void {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::getSharesSharedByMe(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials['username'],
|
||||
$credentials['password']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the JSON data of the response should (not )?contain file name "([^"]*)" with the following data:?$/
|
||||
*
|
||||
* @param string $shouldOrNot (not| )
|
||||
* @param string $fileName
|
||||
* @param PyStringNode $schemaString
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theJsonDataResponseShouldOrNotContainSharedByMeDetails(
|
||||
string $shouldOrNot,
|
||||
string $fileName,
|
||||
PyStringNode $schemaString
|
||||
): void {
|
||||
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent()->value;
|
||||
$fileOrFolderFound = false;
|
||||
foreach ($responseBody as $value) {
|
||||
if (isset($value->name) && $value->name === $fileName) {
|
||||
$responseBody = $value;
|
||||
$fileOrFolderFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$shouldContain = \trim($shouldOrNot) !== 'not';
|
||||
if (!$shouldContain && !$fileOrFolderFound) {
|
||||
return;
|
||||
}
|
||||
Assert::assertFalse(
|
||||
!$shouldContain && $fileOrFolderFound,
|
||||
'Response contains file "' . $fileName . '" but should.'
|
||||
);
|
||||
$this->featureContext->assertJsonDocumentMatchesSchema(
|
||||
$responseBody,
|
||||
$this->featureContext->getJSONSchema($schemaString)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user