Skip to content

Commit 0dcf1a5

Browse files
committed
Fix tests
1 parent 2ea5cb3 commit 0dcf1a5

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

src/Filesystem/Attribute/PendingUploadedFile.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class PendingUploadedFile
2828
public function __construct(
2929
public ?string $path = null,
3030
public ?array $constraints = null,
31-
public int $errorStatus = 422,
3231
public ?bool $image = null,
3332
) {
3433
}

src/Filesystem/Attribute/UploadedFile.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ public function __construct(
2929
string|Namer|null $namer = null,
3030
?string $path = null,
3131
?array $constraints = null,
32-
int $errorStatus = 422,
3332
?bool $image = null,
3433
) {
35-
parent::__construct($path, $constraints, $errorStatus, $image);
34+
parent::__construct($path, $constraints, $image);
3635

3736
$this->namer = $namer ?? new Expression('{checksum}/{name}{ext}');
3837
}

src/Filesystem/Symfony/Exception/IncorrectFileHttpException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
namespace Zenstruck\Filesystem\Symfony\Exception;
1313

14-
use Symfony\Component\HttpKernel\Exception\HttpException;
14+
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
1515

1616
/**
1717
* @author Jakub Caban <[email protected]>
1818
*/
19-
class IncorrectFileHttpException extends HttpException
19+
class IncorrectFileHttpException extends UnprocessableEntityHttpException
2020
{
2121
}

src/Filesystem/Symfony/HttpKernel/PendingFileValueResolverTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
6565
if (\count($errors)) {
6666
\assert($errors instanceof ConstraintViolationList);
6767

68-
throw new IncorrectFileHttpException($attribute->errorStatus, (string) $errors);
68+
throw new IncorrectFileHttpException((string) $errors);
6969
}
7070
}
7171

tests/Filesystem/Symfony/HttpKernel/PendingDocumentValueResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function returns_exception_for_invalid_file(): void
178178
);
179179
$response = $client->getResponse();
180180

181-
self::assertSame(500, $response->getStatusCode());
181+
self::assertSame(422, $response->getStatusCode());
182182
}
183183
}
184184

tests/Fixtures/Controller/ValidatedArgumentResolverController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class ValidatedArgumentResolverController
2525
#[Route('/validated-file', name: 'validated-file')]
2626
public function validatedFile(
2727
#[PendingUploadedFile(
28-
constraints: [new PendingFileConstraint(mimeTypes: ['application/pdf'])],
29-
errorStatus: 500
28+
constraints: [new PendingFileConstraint(mimeTypes: ['application/pdf'])]
3029
)]
3130
File $file
3231
): Response {

0 commit comments

Comments
 (0)