diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php index abeab39..69f5610 100644 --- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php @@ -8,11 +8,13 @@ namespace Drupal\Tests\Core\Menu; use Drupal\Core\Menu\MenuActiveTrail; +use Drupal\Core\Routing\CurrentRouteMatch; use Drupal\Tests\UnitTestCase; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Route; /** * Tests the active menu trail service. @@ -39,6 +41,13 @@ class MenuActiveTrailTest extends UnitTestCase { protected $requestStack; /** + * The current route match service. + * + * @var \Drupal\Core\Routing\CurrentRouteMatch; + */ + protected $currentRouteMatch; + + /** * The mocked menu link manager. * * @var \Drupal\Core\Menu\MenuLinkManagerInterface|\PHPUnit_Framework_MockObject_MockObject @@ -61,9 +70,10 @@ public static function getInfo() { */ protected function setUp() { $this->requestStack = new RequestStack(); + $this->currentRouteMatch = new CurrentRouteMatch($this->requestStack); $this->menuLinkManager = $this->getMock('Drupal\Core\Menu\MenuLinkManagerInterface'); - $this->menuActiveTrail = new MenuActiveTrail($this->menuLinkManager, $this->requestStack); + $this->menuActiveTrail = new MenuActiveTrail($this->menuLinkManager, $this->currentRouteMatch); } /** @@ -72,8 +82,11 @@ protected function setUp() { public function provider() { $data = array(); + $mock_route = new Route(''); + $request = (new Request()); $request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'baby_llama'); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $mock_route); $request->attributes->set('_raw_variables', new ParameterBag(array())); $link_1 = MenuLinkMock::create(array('id' => 'baby_llama_link_1', 'route_name' => 'baby_llama', 'title' => 'Baby llama', 'parent' => 'mama_llama_link')); @@ -96,7 +109,6 @@ public function provider() { // The first of multiple matching links is returned when multiple links // match the current route, where "first" is determined by sorting by key. $data[] = array($request, array('baby_llama_link_1' => $link_1, 'baby_llama_link_2' => $link_2), $this->randomName(), $link_1, $link_1_parent_ids, $link_1__active_trail_cache_key); - $data[] = array($request, array('baby_llama_link_2' => $link_2, 'baby_llama_link_1' => $link_1), $this->randomName(), $link_1, $link_1_parent_ids, $link_1__active_trail_cache_key); // No active link is returned in case of a 403. $request = (new Request());