[FrameworkBundle] fix AbstractController::handleForm()
This commit is contained in:
parent
b14d76921f
commit
777c3c25b2
@ -314,7 +314,7 @@ abstract class AbstractController implements ServiceSubscriberInterface
|
||||
} else {
|
||||
$response = $render($form, $data, $request);
|
||||
|
||||
if ($submitted && 200 === $response->getStatusCode()) {
|
||||
if ($response instanceof Response && $submitted && 200 === $response->getStatusCode()) {
|
||||
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
}
|
||||
|
@ -494,12 +494,12 @@ class AbstractControllerTest extends TestCase
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->expects($this->once())->method('isSubmitted')->willReturn(true);
|
||||
$form->expects($this->once())->method('isValid')->willReturn(true);
|
||||
$form->expects($this->once())->method('isValid')->willReturn(false);
|
||||
|
||||
$controller = $this->createController();
|
||||
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->expectExceptionMessage('The "$onSuccess" callable passed to "Symfony\Bundle\FrameworkBundle\Tests\Controller\TestAbstractController::handleForm()" must return a Response, "string" returned.');
|
||||
$this->expectExceptionMessage('The "$render" callable passed to "Symfony\Bundle\FrameworkBundle\Tests\Controller\TestAbstractController::handleForm()" must return a Response, "string" returned.');
|
||||
|
||||
$response = $controller->handleForm(
|
||||
$form,
|
||||
|
Reference in New Issue
Block a user