function ConfirmFormHelperTest::testCancelLinkRouteWithParams

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

Tests a cancel link route with parameters.

@covers ::buildCancelLink

File

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

Class

ConfirmFormHelperTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21ConfirmFormHelper.php/class/ConfirmFormHelper/11.x" title="Provides common functionality to confirmation forms." class="local">\Drupal\Core\Form\ConfirmFormHelper</a> @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testCancelLinkRouteWithParams() : void {
    $expected = Url::fromRoute('foo_bar.baz', [
        'baz' => 'banana',
    ], [
        'absolute' => TRUE,
    ]);
    $form = $this->createMock('Drupal\\Core\\Form\\ConfirmFormInterface');
    $form->expects($this->any())
        ->method('getCancelUrl')
        ->willReturn($expected);
    $link = ConfirmFormHelper::buildCancelLink($form, new Request());
    $this->assertEquals($expected, $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.