/** * Tests the breadcrumb for a user path. * * @covers ::build() * @covers ::getRequestForPath() */ public function testBuildWithUserPath() { $this->context->expects($this->once())->method('getPathInfo')->will($this->returnValue('/user/1/edit')); $this->setupStubPathProcessor(); $route_1 = new Route('/user/1'); $this->requestMatcher->expects($this->exactly(1))->method('matchRequest')->will($this->returnCallback(function (Request $request) use($route_1) { if ($request->getPathInfo() == '/user/1') { return array(RouteObjectInterface::ROUTE_NAME => 'user_page', RouteObjectInterface::ROUTE_OBJECT => $route_1, '_raw_variables' => new ParameterBag(array())); } })); $this->setupAccessManagerToAllow(); $this->titleResolver->expects($this->once())->method('getTitle')->with($this->anything(), $route_1)->will($this->returnValue('Admin')); $links = $this->builder->build($this->getMock('Drupal\\Core\\Routing\\RouteMatchInterface')); $this->assertEquals(array(0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))), $links); }
/** * Tests the breadcrumb for a user path. * * @covers ::build() * @covers ::getRequestForPath() */ public function testBuildWithUserPath() { $this->context->expects($this->once())->method('getPathInfo')->will($this->returnValue('/user/1/edit')); $this->setupStubPathProcessor(); $route_1 = new Route('/user/1'); $this->requestMatcher->expects($this->exactly(1))->method('matchRequest')->will($this->returnCallback(function (Request $request) use($route_1) { if ($request->getPathInfo() == '/user/1') { return array(RouteObjectInterface::ROUTE_NAME => 'user_page', RouteObjectInterface::ROUTE_OBJECT => $route_1, '_raw_variables' => new ParameterBag(array())); } })); $link_user = '******'; $link_front = '<a href="/">Home</a>'; $this->linkGenerator->expects($this->at(0))->method('generate')->with('Admin', 'user_page', array(), array('html' => TRUE))->will($this->returnValue($link_user)); $this->linkGenerator->expects($this->at(1))->method('generate')->with('Home', '<front>', array(), array())->will($this->returnValue($link_front)); $this->setupAccessManagerWithTrue(); $this->titleResolver->expects($this->once())->method('getTitle')->with($this->anything(), $route_1)->will($this->returnValue('Admin')); $links = $this->builder->build($this->getMock('Drupal\\Core\\Routing\\RouteMatchInterface')); $this->assertEquals(array(0 => '<a href="/">Home</a>', 1 => $link_user), $links); }