You are here

protected function DevelWebAssertHelper::assertLocalTasks in Devel 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/DevelWebAssertHelper.php \Drupal\Tests\devel\Functional\DevelWebAssertHelper::assertLocalTasks()
  2. 8.2 tests/src/Functional/DevelWebAssertHelper.php \Drupal\Tests\devel\Functional\DevelWebAssertHelper::assertLocalTasks()
  3. 4.x tests/src/Functional/DevelWebAssertHelper.php \Drupal\Tests\devel\Functional\DevelWebAssertHelper::assertLocalTasks()

Asserts local tasks in the page output.

Parameters

array $routes: A list of expected local tasks, prepared as an array of route names and their associated route parameters, to assert on the page (in the given order).

int $level: (optional) The local tasks level to assert; 0 for primary, 1 for secondary. Defaults to 0.

1 call to DevelWebAssertHelper::assertLocalTasks()
DevelContainerInfoTest::assertContainerInfoLocalTasks in tests/src/Functional/DevelContainerInfoTest.php
Asserts that container info local tasks are present.

File

tests/src/Functional/DevelWebAssertHelper.php, line 23

Class

DevelWebAssertHelper
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\Tests\devel\Functional

Code

protected function assertLocalTasks(array $routes, $level = 0) {
  $type_class = $level == 0 ? 'tabs primary' : 'tabs secondary';
  $elements = $this
    ->xpath('//*[contains(@class, :class)]//a', [
    ':class' => $type_class,
  ]);
  $this
    ->assertTrue(count($elements), 'Local tasks found.');
  foreach ($routes as $index => $route_info) {
    list($route_name, $route_parameters) = $route_info;
    $expected = Url::fromRoute($route_name, $route_parameters)
      ->toString();
    $this
      ->assertEquals($expected, $elements[$index]
      ->getAttribute('href'));
  }
}