コード例 #1
0
ファイル: Simple.php プロジェクト: indigophp/simple-cart
 /**
  * {@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;
 }
コード例 #2
0
ファイル: SimpleSpec.php プロジェクト: indigophp/simple-cart
 function it_clears_items(Item $item)
 {
     $item->getId()->willReturn('_ITEM_');
     $this->addItem($item);
     $this->clear()->shouldReturn(true);
     $this->isEmpty()->shouldBe(true);
 }