public function testSetter()
 {
     $node = new BreadcrumbsNode();
     $node->setPath('/');
     $node->setLabel('index');
     $this->assertEquals('/', $node->getPath());
     $this->assertEquals('index', $node->getLabel());
 }
 public function testArrayAccess()
 {
     $node1 = new BreadcrumbsNode();
     $node1->setPath('/');
     $node1->setLabel('index');
     $node2 = new BreadcrumbsNode();
     $node2->setPath('/foo');
     $node2->setLabel('foo');
     $this->breadcrumbs[] = $node1;
     $this->breadcrumbs[23] = $node2;
     $this->assertCount(2, $this->breadcrumbs);
     $this->assertTrue(isset($this->breadcrumbs[0]));
     $this->assertEquals($node1, $this->breadcrumbs[0]);
     $this->assertEquals($node2, $this->breadcrumbs[23]);
     $this->assertNull($this->breadcrumbs[1]);
     unset($this->breadcrumbs[0]);
     $this->assertCount(1, $this->breadcrumbs);
 }
 /**
  * Create a breadcrumbs node from path
  *
  * @param string $path
  * @param string $parent
  *
  * @return BreadcrumbsNode|bool
  */
 private function createBreadcrumbsNode($path, $parent)
 {
     // use $baseUrl for no prod environments e.g dev 'app_dev.php'
     $baseUrl = $this->getRequest()->getBaseUrl();
     $traces = $this->matcher->getTraces($path);
     foreach ($traces as $trace) {
         if (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
             $label = $this->getLabel($path, $parent, $trace['name']);
             $node = new BreadcrumbsNode();
             $node->setLabel($label);
             $node->setPath($baseUrl . $path);
             return $node;
         }
     }
     return false;
 }