You are here

public function ConfirmFormHelperTest::testCancelLinkRouteWithUrl in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php \Drupal\Tests\Core\Form\ConfirmFormHelperTest::testCancelLinkRouteWithUrl()

@covers ::buildCancelLink

Tests a cancel link route with a URL object.

File

core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php, line 77
Contains \Drupal\Tests\Core\Form\ConfirmFormHelperTest.

Class

ConfirmFormHelperTest
@coversDefaultClass \Drupal\Core\Form\ConfirmFormHelper @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testCancelLinkRouteWithUrl() {
  $cancel_route = new Url('foo_bar.baz', array(
    'baz' => 'banana',
  ), array(
    'absolute' => TRUE,
  ));
  $form = $this
    ->getMock('Drupal\\Core\\Form\\ConfirmFormInterface');
  $form
    ->expects($this
    ->any())
    ->method('getCancelUrl')
    ->will($this
    ->returnValue($cancel_route));
  $link = ConfirmFormHelper::buildCancelLink($form, new Request());
  $this
    ->assertSame($cancel_route, $link['#url']);
  $this
    ->assertSame([
    'contexts' => [
      'url.query_args:destination',
    ],
  ], $link['#cache']);
}