|
23 | 23 | use Symfony\Component\Form\FormConfigInterface;
|
24 | 24 | use Symfony\Component\Form\FormError;
|
25 | 25 | use Symfony\Component\Form\FormFactoryInterface;
|
26 |
| -use Symfony\Component\Form\FormInterface; |
27 | 26 | use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
28 | 27 | use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
29 | 28 | use Symfony\Component\HttpFoundation\File\File;
|
@@ -463,100 +462,6 @@ public function testStreamTwig()
|
463 | 462 | $this->assertInstanceOf(StreamedResponse::class, $controller->stream('foo'));
|
464 | 463 | }
|
465 | 464 |
|
466 |
| - /** |
467 |
| - * @group legacy |
468 |
| - */ |
469 |
| - public function testHandleFormNotSubmitted() |
470 |
| - { |
471 |
| - $form = $this->createMock(FormInterface::class); |
472 |
| - $form->expects($this->once())->method('isSubmitted')->willReturn(false); |
473 |
| - |
474 |
| - $controller = $this->createController(); |
475 |
| - $response = $controller->handleForm( |
476 |
| - $form, |
477 |
| - Request::create('https://example.com'), |
478 |
| - function (FormInterface $form, $data, Request $request): Response { |
479 |
| - return new RedirectResponse('https://example.com/redir', Response::HTTP_SEE_OTHER); |
480 |
| - }, |
481 |
| - function (FormInterface $form, $data, Request $request): Response { |
482 |
| - return new Response('rendered'); |
483 |
| - } |
484 |
| - ); |
485 |
| - |
486 |
| - $this->assertTrue($response->isSuccessful()); |
487 |
| - $this->assertSame('rendered', $response->getContent()); |
488 |
| - } |
489 |
| - |
490 |
| - /** |
491 |
| - * @group legacy |
492 |
| - */ |
493 |
| - public function testHandleFormInvalid() |
494 |
| - { |
495 |
| - $form = $this->createMock(FormInterface::class); |
496 |
| - $form->expects($this->once())->method('isSubmitted')->willReturn(true); |
497 |
| - $form->expects($this->once())->method('isValid')->willReturn(false); |
498 |
| - |
499 |
| - $controller = $this->createController(); |
500 |
| - $response = $controller->handleForm( |
501 |
| - $form, |
502 |
| - Request::create('https://example.com'), |
503 |
| - function (FormInterface $form, $data, Request $request): Response { |
504 |
| - return new RedirectResponse('https://example.com/redir', Response::HTTP_SEE_OTHER); |
505 |
| - }, |
506 |
| - function (FormInterface $form, $data, Request $request): Response { |
507 |
| - return new Response('rendered'); |
508 |
| - } |
509 |
| - ); |
510 |
| - |
511 |
| - $this->assertSame(Response::HTTP_UNPROCESSABLE_ENTITY, $response->getStatusCode()); |
512 |
| - $this->assertSame('rendered', $response->getContent()); |
513 |
| - } |
514 |
| - |
515 |
| - /** |
516 |
| - * @group legacy |
517 |
| - */ |
518 |
| - public function testHandleFormValid() |
519 |
| - { |
520 |
| - $form = $this->createMock(FormInterface::class); |
521 |
| - $form->expects($this->once())->method('isSubmitted')->willReturn(true); |
522 |
| - $form->expects($this->once())->method('isValid')->willReturn(true); |
523 |
| - |
524 |
| - $controller = $this->createController(); |
525 |
| - $response = $controller->handleForm( |
526 |
| - $form, |
527 |
| - Request::create('https://example.com'), |
528 |
| - function (FormInterface $form, $data, Request $request): Response { |
529 |
| - return new RedirectResponse('https://example.com/redir', Response::HTTP_SEE_OTHER); |
530 |
| - }, |
531 |
| - function (FormInterface $form, $data, Request $request): Response { |
532 |
| - return new Response('rendered'); |
533 |
| - } |
534 |
| - ); |
535 |
| - |
536 |
| - $this->assertInstanceOf(RedirectResponse::class, $response); |
537 |
| - $this->assertSame(Response::HTTP_SEE_OTHER, $response->getStatusCode()); |
538 |
| - $this->assertSame('https://example.com/redir', $response->getTargetUrl()); |
539 |
| - } |
540 |
| - |
541 |
| - public function testHandleFormTypeError() |
542 |
| - { |
543 |
| - $form = $this->createMock(FormInterface::class); |
544 |
| - $form->expects($this->once())->method('isSubmitted')->willReturn(true); |
545 |
| - $form->expects($this->once())->method('isValid')->willReturn(true); |
546 |
| - |
547 |
| - $controller = $this->createController(); |
548 |
| - |
549 |
| - $this->expectException(\TypeError::class); |
550 |
| - $this->expectExceptionMessage('The "$onSuccess" callable passed to "Symfony\Bundle\FrameworkBundle\Tests\Controller\TestAbstractController::handleForm()" must return a Response, "string" returned.'); |
551 |
| - |
552 |
| - $response = $controller->handleForm( |
553 |
| - $form, |
554 |
| - Request::create('https://example.com'), |
555 |
| - function () { return 'abc'; }, |
556 |
| - function () { return 'abc'; } |
557 |
| - ); |
558 |
| - } |
559 |
| - |
560 | 465 | public function testRedirectToRoute()
|
561 | 466 | {
|
562 | 467 | $router = $this->createMock(RouterInterface::class);
|
|
0 commit comments