public function ConfirmFormHelperTest::testCancelLinkDestination in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkDestination()
@covers ::buildCancelLink
Tests a cancel link provided by the destination.
@dataProvider providerTestCancelLinkDestination
File
- core/
tests/ Drupal/ Tests/ Core/ Form/ ConfirmFormHelperTest.php, line 97
Class
- ConfirmFormHelperTest
- @coversDefaultClass \Drupal\Core\Form\ConfirmFormHelper @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testCancelLinkDestination($destination) {
$query = [
'destination' => $destination,
];
$form = $this
->createMock('Drupal\\Core\\Form\\ConfirmFormInterface');
$path_validator = $this
->createMock('Drupal\\Core\\Path\\PathValidatorInterface');
$container_builder = new ContainerBuilder();
$container_builder
->set('path.validator', $path_validator);
\Drupal::setContainer($container_builder);
$url = Url::fromRoute('test_route');
$path_validator
->expects($this
->atLeastOnce())
->method('getUrlIfValidWithoutAccessCheck')
->with('baz')
->willReturn($url);
$link = ConfirmFormHelper::buildCancelLink($form, new Request($query));
$this
->assertSame($url, $link['#url']);
$this
->assertSame([
'contexts' => [
'url.query_args:destination',
],
], $link['#cache']);
}