Exemplo n.º 1
0
 public function testAddItem()
 {
     $cartId = 13;
     $this->dataMock->expects($this->once())->method('getQty')->will($this->returnValue(12));
     $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->will($this->returnValue($this->quoteMock));
     $this->productLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->productMock));
     $this->dataMock->expects($this->once())->method('getSku');
     $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12);
     $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->once())->method('save');
     $this->quoteMock->expects($this->once())->method('getItemByProduct')->with($this->productMock)->will($this->returnValue($this->quoteItemMock));
     $this->quoteItemMock->expects($this->once())->method('getId')->will($this->returnValue(5));
     $this->assertEquals(5, $this->service->addItem($cartId, $this->dataMock));
 }