/** * {@inheritdoc} */ public function addItem(Item $item) { $id = $item->getId(); if ($this->hasItem($id)) { $currentItem = $this->getItem($id); $currentItem->changeQuantity($item->getQuantity()); return; } $this->items[$id] = $item; }
function it_clears_items(Item $item) { $item->getId()->willReturn('_ITEM_'); $this->addItem($item); $this->clear()->shouldReturn(true); $this->isEmpty()->shouldBe(true); }