public function FormSubmitterTest::testRedirectWithUrl in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php \Drupal\Tests\Core\Form\FormSubmitterTest::testRedirectWithUrl()
Tests redirectForm() when a redirect is a Url object.
@covers ::redirectForm
@dataProvider providerTestRedirectWithUrl
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ FormSubmitterTest.php, line 139 - Contains \Drupal\Tests\Core\Form\FormSubmitterTest.
Class
- FormSubmitterTest
- @coversDefaultClass \Drupal\Core\Form\FormSubmitter @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testRedirectWithUrl(Url $redirect_value, $result, $status = 303) {
$container = new ContainerBuilder();
$container
->set('url_generator', $this->urlGenerator);
\Drupal::setContainer($container);
$form_submitter = $this
->getFormSubmitter();
$this->urlGenerator
->expects($this
->once())
->method('generateFromRoute')
->will($this
->returnValueMap(array(
array(
'test_route_a',
array(),
array(
'absolute' => TRUE,
),
FALSE,
'test-route',
),
array(
'test_route_b',
array(
'key' => 'value',
),
array(
'absolute' => TRUE,
),
FALSE,
'test-route/value',
),
)));
$form_state = $this
->getMock('Drupal\\Core\\Form\\FormStateInterface');
$form_state
->expects($this
->once())
->method('getRedirect')
->willReturn($redirect_value);
$redirect = $form_submitter
->redirectForm($form_state);
$this
->assertSame($result, $redirect
->getTargetUrl());
$this
->assertSame($status, $redirect
->getStatusCode());
}