From 2330a7b70a891c88a2d5e986e64dd659250f0302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20G=C3=B6r=C3=B6g?= Date: Wed, 10 Jun 2020 17:56:28 +0200 Subject: [PATCH] Fix Resumable.js response code on test request --- src/Driver/ResumableJsUploadDriver.php | 3 +-- tests/Driver/ResumableJsUploadDriverTest.php | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Driver/ResumableJsUploadDriver.php b/src/Driver/ResumableJsUploadDriver.php index d4b0139..705e4ba 100644 --- a/src/Driver/ResumableJsUploadDriver.php +++ b/src/Driver/ResumableJsUploadDriver.php @@ -14,7 +14,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class ResumableJsUploadDriver extends UploadDriver { @@ -106,7 +105,7 @@ public function resume(Request $request, StorageConfig $config): Response $chunkname = $this->buildChunkname($range); if (! $this->chunkExists($config, $filename, $chunkname)) { - throw new NotFoundHttpException(); + return new Response('', Response::HTTP_NO_CONTENT); } return new JsonResponse(['OK']); diff --git a/tests/Driver/ResumableJsUploadDriverTest.php b/tests/Driver/ResumableJsUploadDriverTest.php index 3672349..4420ac5 100644 --- a/tests/Driver/ResumableJsUploadDriverTest.php +++ b/tests/Driver/ResumableJsUploadDriverTest.php @@ -13,9 +13,9 @@ use LaraCrafts\ChunkUploader\Tests\TestCase; use LaraCrafts\ChunkUploader\UploadHandler; use Mockery; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class ResumableJsUploadDriverTest extends TestCase { @@ -85,9 +85,8 @@ public function testResumeWhenChunkDoesNotExists() 'resumableType' => 'text/plain', ]); - $this->expectException(NotFoundHttpException::class); - - $this->createTestResponse($this->handler->handle($request)); + $response = $this->createTestResponse($this->handler->handle($request)); + $response->assertStatus(Response::HTTP_NO_CONTENT); } public function testResume()