mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 17:00:57 -06:00
add test to download preview with all processors
Signed-off-by: prashant-gurung899 <prasantgrg777@gmail.com>
This commit is contained in:
@@ -145,7 +145,6 @@ class FeatureContext extends BehatVariablesContext {
|
||||
private int $ocsApiVersion = 1;
|
||||
private ?ResponseInterface $response = null;
|
||||
private string $responseUser = '';
|
||||
private ?string $responseBodyContent = null;
|
||||
public array $emailRecipients = [];
|
||||
private CookieJar $cookieJar;
|
||||
private string $requestToken;
|
||||
|
||||
@@ -3741,6 +3741,40 @@ trait WebDav {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user downloads the preview of :path with width :width and height :height and processor :processor using the WebDAV API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $path
|
||||
* @param string $width
|
||||
* @param string $height
|
||||
* @param string $processor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function userDownloadsThePreviewOfWithWidthHeightProcessorUsingWebDAVAPI(string $user, string $path, string $width, string $height, string $processor): void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$urlParameter = [
|
||||
'x' => $width,
|
||||
'y' => $height,
|
||||
'preview' => '1',
|
||||
'processor' => $processor
|
||||
];
|
||||
$response = $this->makeDavRequest(
|
||||
$user,
|
||||
"GET",
|
||||
$path,
|
||||
[],
|
||||
null,
|
||||
"files",
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
$urlParameter,
|
||||
);
|
||||
$this->setResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given user :user has downloaded the preview of shared resource :path with width :width and height :height
|
||||
*
|
||||
@@ -3760,8 +3794,9 @@ trait WebDav {
|
||||
$this->setResponse($response);
|
||||
$this->theHTTPStatusCodeShouldBe(200, '', $response);
|
||||
$this->checkImageDimensions($width, $height);
|
||||
$response->getBody()->rewind();
|
||||
// save response to user response dictionary for further comparisons
|
||||
$this->userResponseBodyContents[$user] = $this->responseBodyContent;
|
||||
$this->userResponseBodyContents[$user] = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3953,10 +3988,9 @@ trait WebDav {
|
||||
*/
|
||||
public function checkImageDimensions(string $width, string $height, ?ResponseInterface $response = null) : void {
|
||||
$response = $response ?? $this->getResponse();
|
||||
if ($this->responseBodyContent === null) {
|
||||
$this->responseBodyContent = $response->getBody()->getContents();
|
||||
}
|
||||
$size = \getimagesizefromstring($this->responseBodyContent);
|
||||
$response->getBody()->rewind();
|
||||
$responseBodyContent = $response->getBody()->getContents();
|
||||
$size = \getimagesizefromstring($responseBodyContent);
|
||||
Assert::assertNotFalse($size, "could not get size of image");
|
||||
Assert::assertEquals($width, $size[0], "width not as expected");
|
||||
Assert::assertEquals($height, $size[1], "height not as expected");
|
||||
@@ -3972,7 +4006,10 @@ trait WebDav {
|
||||
*/
|
||||
public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename):void {
|
||||
$expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename);
|
||||
Assert::assertEquals($expectedPreview, $this->responseBodyContent);
|
||||
$response = $response ?? $this->getResponse();
|
||||
$response->getBody()->rewind();
|
||||
$responseBodyContent = $response->getBody()->getContents();
|
||||
Assert::assertEquals($expectedPreview, $responseBodyContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3995,8 +4032,9 @@ trait WebDav {
|
||||
);
|
||||
$this->theHTTPStatusCodeShouldBe(200, "", $response);
|
||||
$this->checkImageDimensions($width, $height, $response);
|
||||
$response->getBody()->rewind();
|
||||
// save response to user response dictionary for further comparisons
|
||||
$this->userResponseBodyContents[$user] = $this->responseBodyContent;
|
||||
$this->userResponseBodyContents[$user] = $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -344,3 +344,25 @@ Feature: previews of files downloaded through the webdav API
|
||||
| old |
|
||||
| new |
|
||||
| spaces |
|
||||
|
||||
|
||||
Scenario Outline: download previews of an image with different processors
|
||||
Given using <dav-path-version> DAV path
|
||||
And user "Alice" has uploaded file "filesForUpload/testavatar.jpg" to "/testimage.jpg"
|
||||
When user "Alice" downloads the preview of "/testimage.jpg" with width "32" and height "32" and processor <processor> using the WebDAV API
|
||||
Then the HTTP status code should be "200"
|
||||
And the downloaded preview content should match with <expected-image> fixtures preview content
|
||||
Examples:
|
||||
| dav-path-version | processor | expected-image |
|
||||
| old | fit | fit.png |
|
||||
| old | fill | fill.png |
|
||||
| old | resize | resize.png |
|
||||
| old | thumbnail | thumbnail.png |
|
||||
| new | fit | fit.png |
|
||||
| new | fill | fill.png |
|
||||
| new | resize | resize.png |
|
||||
| new | thumbnail | thumbnail.png |
|
||||
| spaces | fit | fit.png |
|
||||
| spaces | fill | fill.png |
|
||||
| spaces | resize | resize.png |
|
||||
| spaces | thumbnail | thumbnail.png |
|
||||
|
||||
BIN
tests/acceptance/fixtures/fill.png
Normal file
BIN
tests/acceptance/fixtures/fill.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 874 B |
BIN
tests/acceptance/fixtures/fit.png
Normal file
BIN
tests/acceptance/fixtures/fit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 713 B |
BIN
tests/acceptance/fixtures/resize.png
Normal file
BIN
tests/acceptance/fixtures/resize.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 829 B |
BIN
tests/acceptance/fixtures/thumbnail.png
Normal file
BIN
tests/acceptance/fixtures/thumbnail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 874 B |
Reference in New Issue
Block a user