You are here

public function MenuActiveTrailTest::testGetActiveLink in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveLink()

Tests getActiveLink().

@covers ::getActiveLink @dataProvider provider

File

core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php, line 147
Contains \Drupal\Tests\Core\Menu\MenuActiveTrailTest.

Class

MenuActiveTrailTest
Tests the active menu trail service.

Namespace

Drupal\Tests\Core\Menu

Code

public function testGetActiveLink(Request $request, $links, $menu_name, $expected_link) {
  $this->requestStack
    ->push($request);
  if ($links !== FALSE) {
    $this->menuLinkManager
      ->expects($this
      ->exactly(2))
      ->method('loadLinksbyRoute')
      ->with('baby_llama')
      ->will($this
      ->returnValue($links));
  }

  // Test with menu name.
  $this
    ->assertSame($expected_link, $this->menuActiveTrail
    ->getActiveLink($menu_name));

  // Test without menu name.
  $this
    ->assertSame($expected_link, $this->menuActiveTrail
    ->getActiveLink());
}