Skip to content

Commit d5d589d

Browse files
[FrameworkBundle] fix AbstractController::handleForm()
1 parent 70bd811 commit d5d589d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Controller/AbstractController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public function handleForm(FormInterface $form, Request $request, callable $onSu
314314
} else {
315315
$response = $render($form, $data, $request);
316316

317-
if ($submitted && 200 === $response->getStatusCode()) {
317+
if ($response instanceof Response && $submitted && 200 === $response->getStatusCode()) {
318318
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
319319
}
320320
}

Tests/Controller/AbstractControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,12 @@ public function testHandleFormTypeError()
494494
{
495495
$form = $this->createMock(FormInterface::class);
496496
$form->expects($this->once())->method('isSubmitted')->willReturn(true);
497-
$form->expects($this->once())->method('isValid')->willReturn(true);
497+
$form->expects($this->once())->method('isValid')->willReturn(false);
498498

499499
$controller = $this->createController();
500500

501501
$this->expectException(\TypeError::class);
502-
$this->expectExceptionMessage('The "$onSuccess" callable passed to "Symfony\Bundle\FrameworkBundle\Tests\Controller\TestAbstractController::handleForm()" must return a Response, "string" returned.');
502+
$this->expectExceptionMessage('The "$render" callable passed to "Symfony\Bundle\FrameworkBundle\Tests\Controller\TestAbstractController::handleForm()" must return a Response, "string" returned.');
503503

504504
$response = $controller->handleForm(
505505
$form,

0 commit comments

Comments
 (0)