Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST]: ImagineController functional test fixes #1087

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Tests/Functional/Controller/ImagineControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,43 @@ public function testShouldResolveFromCache()
$this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg');
}

public function testThrowBadRequestIfSignInvalidWhileUsingCustomFilters()
public function testBadRequestIfSignInvalidWhileUsingCustomFilters()
{
$this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class);
$this->expectExceptionMessage('Signed url does not pass the sign check for path "images/cats.jpeg" and filter "thumbnail_web_path" and runtime config {"thumbnail":{"size":["50","50"]}}');

$this->client->request('GET', '/media/cache/resolve/thumbnail_web_path/rc/invalidHash/images/cats.jpeg?'.http_build_query([
'filters' => [
'thumbnail' => ['size' => [50, 50]],
],
'_hash' => 'invalid',
]));

$response = $this->client->getResponse();
$this->assertSame(400, $response->getStatusCode());
}

public function testShouldThrowNotFoundHttpExceptionIfFiltersNotArray()
public function testShouldReturnNotFoundHttpCodeIfFiltersNotArray()
{
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
$this->expectExceptionMessage('Filters must be an array. Value was "some-string"');

$this->client->request('GET', '/media/cache/resolve/thumbnail_web_path/rc/invalidHash/images/cats.jpeg?'.http_build_query([
'filters' => 'some-string',
'_hash' => 'hash',
]));
$response = $this->client->getResponse();
$this->assertSame(404, $response->getStatusCode());
}

public function testShouldThrowNotFoundHttpExceptionIfFileNotExists()
public function testShouldReturnNotFoundHttpCodeIfFileNotExists()
{
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);
$this->expectExceptionMessage('Source image for path "images/shrodinger_cats_which_not_exist.jpeg" could not be found');

$this->client->request('GET', '/media/cache/resolve/thumbnail_web_path/images/shrodinger_cats_which_not_exist.jpeg');
$response = $this->client->getResponse();
$this->assertSame(404, $response->getStatusCode());
}

public function testInvalidFilterShouldThrowNotFoundHttpException()
public function testInvalidFilterShouldReturnNotFoundHttpCode()
{
$this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class);

$this->client->request('GET', '/media/cache/resolve/invalid-filter/images/cats.jpeg');

$response = $this->client->getResponse();
$this->assertSame(404, $response->getStatusCode());

}

public function testShouldResolveWithCustomFiltersPopulatingCacheFirst()
Expand Down