function MenuActiveTrailTest::testGetActiveLink

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveLink()
  2. 10 core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php \Drupal\Tests\Core\Menu\MenuActiveTrailTest::testGetActiveLink()
  3. 11.x 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 142

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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.