/**
  * 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);
 }
 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumbs = parent::build($route_match);
     $request = \Drupal::request();
     $path = trim($this->context->getPathInfo(), '/');
     $path_elements = explode('/', $path);
     $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     if ($route && !\Drupal::service('router.admin_context')->isAdminRoute()) {
         $title = \Drupal::service('title_resolver')->getTitle($request, $route);
         if (!isset($title)) {
             // Fallback to using the raw path component as the title if the
             // route is missing a _title or _title_callback attribute.
             $title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
         }
         $breadcrumbs->addLink(Link::createFromRoute($title, '<none>'));
     }
     return $breadcrumbs;
 }
 /**
  * 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);
 }
 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $build = parent::build($route_match);
     array_pop($build);
     return $build;
 }