Example #1
0
 /**
  * @inheritdoc
  */
 public function setCart(Cart $cart)
 {
     $lineItems = $cart->getLineItems()->map(function (LineItem $lineItem) {
         return $lineItem->getQuantity()->getValue();
     });
     $this->session->set(self::NAME, $lineItems->toArray());
 }
Example #2
0
 public function testAddSameProducts()
 {
     $uuid1 = $this->getUuidMock(['getValue']);
     $uuid1->expects($this->exactly(2))->method('getValue')->willReturn('xxx');
     $product1 = $this->getProductMock(['getId']);
     $product1->expects($this->exactly(2))->method('getId')->willReturn($uuid1);
     $cart = new Cart(new ArrayCollection());
     $cart->addProduct($product1, new Quantity(2));
     $cart->addProduct($product1, new Quantity(4));
     $collection = $cart->getLineItems();
     $this->assertCount(1, $collection);
     $this->assertSame($product1, $collection->get('xxx')->getProduct());
     $this->assertSame(6, $collection->get('xxx')->getQuantity()->getValue());
 }