You are here

protected function LocalTasksTest::assertLocalTaskAppears in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php \Drupal\Tests\system\Functional\Menu\LocalTasksTest::assertLocalTaskAppears()
  2. 10 core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php \Drupal\Tests\system\Functional\Menu\LocalTasksTest::assertLocalTaskAppears()

Ensures that some local task appears.

Parameters

string $title: The expected title.

Return value

bool TRUE if the local task exists on the page.

1 call to LocalTasksTest::assertLocalTaskAppears()
LocalTasksTest::testPluginLocalTask in core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php
Tests the plugin based local tasks.

File

core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php, line 76

Class

LocalTasksTest
Tests local tasks derived from router and added/altered via hooks.

Namespace

Drupal\Tests\system\Functional\Menu

Code

protected function assertLocalTaskAppears($title) {

  // SimpleXML gives us the unescaped text, not the actual escaped markup,
  // so use a pattern instead to check the raw content.
  // This behavior is a bug in libxml, see
  // https://bugs.php.net/bug.php?id=49437.
  return $this
    ->assertSession()
    ->responseMatches('@<a [^>]*>' . preg_quote($title, '@') . '</a>@');
}