You are here

protected function MenuRouterTest::doTestHookMenuIntegration in Drupal 8

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

Test 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
    ->assertText('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
    ->assertEscaped("<script>alert('Welcome to the jungle!')</script>");

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