From 7530048fbdd0b530c175a3ddbca9b8b46161af05 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 24 Mar 2017 21:58:56 +0100 Subject: [PATCH] Removed exception catch that used to return a 500, and now returns a 404 due to a behavior change --- data/proxies/.gitignore | 0 module/Core/src/Action/PreviewAction.php | 2 -- module/Core/test/Action/PreviewActionTest.php | 20 ------------------- 3 files changed, 22 deletions(-) mode change 100644 => 100755 data/proxies/.gitignore diff --git a/data/proxies/.gitignore b/data/proxies/.gitignore old mode 100644 new mode 100755 diff --git a/module/Core/src/Action/PreviewAction.php b/module/Core/src/Action/PreviewAction.php index 4c21501c..f2145e1b 100644 --- a/module/Core/src/Action/PreviewAction.php +++ b/module/Core/src/Action/PreviewAction.php @@ -78,8 +78,6 @@ class PreviewAction implements MiddlewareInterface return $this->generateImageResponse($imagePath); } catch (InvalidShortCodeException $e) { return $out($request, $response->withStatus(404), 'Not found'); - } catch (PreviewGenerationException $e) { - return $out($request, $response->withStatus(500), 'Preview generation error'); } } } diff --git a/module/Core/test/Action/PreviewActionTest.php b/module/Core/test/Action/PreviewActionTest.php index 2e8e0149..8ef2883a 100644 --- a/module/Core/test/Action/PreviewActionTest.php +++ b/module/Core/test/Action/PreviewActionTest.php @@ -91,24 +91,4 @@ class PreviewActionTest extends TestCase $this->assertEquals(404, $resp->getStatusCode()); } - - /** - * @test - */ - public function previewExceptionReturnsNotFound() - { - $shortCode = 'abc123'; - $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(PreviewGenerationException::class) - ->shouldBeCalledTimes(1); - - $resp = $this->action->__invoke( - ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), - new Response(), - function ($req, $resp) { - return $resp; - } - ); - - $this->assertEquals(500, $resp->getStatusCode()); - } }