/** * {@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_has_a_quantity(Item $item) { $item->getId()->willReturn('_ITEM_'); $item->getQuantity()->willReturn(1); $this->addItem($item); $this->getQuantity()->shouldReturn(1); }