You are here

protected function MenuRouterTest::doTestHookMenuIntegration in Drupal 10

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

Tests local tasks with route placeholders.

1 call to MenuRouterTest::doTestHookMenuIntegration()
MenuRouterTest::testMenuIntegration in core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
Tests menu integration.

File

core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php, line 60

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

protected function doTestHookMenuIntegration() {

  // Generate base path with random argument.
  $machine_name = $this
    ->randomMachineName(8);
  $base_path = 'foo/' . $machine_name;
  $this
    ->drupalGet($base_path);

  // Confirm correct controller activated.
  $this
    ->assertSession()
    ->pageTextContains('test1');

  // Confirm local task links are displayed.
  $this
    ->assertSession()
    ->linkExists('Local task A');
  $this
    ->assertSession()
    ->linkExists('Local task B');
  $this
    ->assertSession()
    ->linkNotExists('Local task C');
  $this
    ->assertSession()
    ->assertEscaped("<script>alert('Welcome to the jungle!')</script>");

  // Confirm correct local task href.
  $this
    ->assertSession()
    ->linkByHrefExists(Url::fromRoute('menu_test.router_test1', [
    'bar' => $machine_name,
  ])
    ->toString());
  $this
    ->assertSession()
    ->linkByHrefExists(Url::fromRoute('menu_test.router_test2', [
    'bar' => $machine_name,
  ])
    ->toString());
}