You are here

public function ConfirmFormTest::assertCancelLinkUrl in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php \Drupal\Tests\system\Functional\Form\ConfirmFormTest::assertCancelLinkUrl()

Asserts that a cancel link is present pointing to the provided URL.

Parameters

\Drupal\Core\Url $url: The url to check for.

string $message: The assert message.

string $group: The assertion group.

1 call to ConfirmFormTest::assertCancelLinkUrl()
ConfirmFormTest::testConfirmFormWithExternalDestination in core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php
Tests that the confirm form does not use external destinations.

File

core/modules/system/tests/src/Functional/Form/ConfirmFormTest.php, line 85

Class

ConfirmFormTest
Tests confirmation forms.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function assertCancelLinkUrl(Url $url, $message = '', $group = 'Other') {
  $links = $this
    ->xpath('//a[@href=:url]', [
    ':url' => $url
      ->toString(),
  ]);
  $message = $message ? $message : new FormattableMarkup('Cancel link with URL %url found.', [
    '%url' => $url
      ->toString(),
  ]);
  $this
    ->assertTrue(isset($links[0]), $message, $group);
}