/** * @covers ::__construct * @covers ::addItem * @covers ::getItems */ public function test_getItems_nonEmptyBreadcrumb() { $item1 = \Mockery::mock(BreadcrumbItem::class); $this->itemFactory->shouldReceive('create')->with('aLabel', 'aRoute', null)->andReturn($item1); $item2 = \Mockery::mock(BreadcrumbItem::class); $this->itemFactory->shouldReceive('create')->with('anotherLabel', 'anotherRoute', ['a' => 'b'])->andReturn($item2); $this->builder->addItem('aLabel', 'aRoute'); $this->builder->addItem('anotherLabel', 'anotherRoute', ['a' => 'b']); $this->assertEquals([$item1, $item2], $this->builder->getItems()); }
/** * Adds a new breadcrumb item. * * @param string $label * @param string|null $route * @param array|null $routeParams */ public function addItem($label, $route = null, array $routeParams = null) { $this->items[] = $this->itemFactory->create($label, $route, $routeParams); }
/** * @covers ::create */ public function test_create() { $factory = new BreadcrumbItemFactory(); $item = $factory->create('aLabel', 'aRoute'); $this->assertTrue($item instanceof BreadcrumbItem); }