function ConfirmFormHelperTest::testCancelLinkRouteWithUrl

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkRouteWithUrl()
  2. 10 core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkRouteWithUrl()
  3. 9 core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkRouteWithUrl()
  4. 8.9.x core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkRouteWithUrl()

Tests a cancel link route with a URL object.

@legacy-covers ::buildCancelLink

File

core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php, line 79

Class

ConfirmFormHelperTest
Tests Drupal\Core\Form\ConfirmFormHelper.

Namespace

Drupal\Tests\Core\Form

Code

public function testCancelLinkRouteWithUrl() : void {
  $cancel_route = new Url('foo_bar.baz', [
    'baz' => 'banana',
  ], [
    'absolute' => TRUE,
  ]);
  $form = $this->createStub(ConfirmFormInterface::class);
  $form->method('getCancelUrl')
    ->willReturn($cancel_route);
  $link = ConfirmFormHelper::buildCancelLink($form, new Request());
  $this->assertSame($cancel_route, $link['#url']);
  $this->assertSame([
    'contexts' => [
      'url.query_args:destination',
    ],
  ], $link['#cache']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.