diff --git a/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php b/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php index e2ef0aa810229f112f453403820d64a0cbc8021d..96787607500b7216d5826ec63141a12741a564bf 100644 --- a/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php +++ b/app/code/Magento/Quote/Api/CartItemRepositoryInterface.php @@ -27,15 +27,6 @@ interface CartItemRepositoryInterface */ public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem); - /** - * Delete cart item - * - * @param \Magento\Quote\Api\Data\CartItemInterface $cartItem - * @return void - * @throws \Magento\Framework\Exception\CouldNotSaveException - */ - public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem); - /** * Removes the specified item from the specified cart. * diff --git a/app/code/Magento/Quote/Model/Quote/Item/Repository.php b/app/code/Magento/Quote/Model/Quote/Item/Repository.php index 0a4374e2e559a6e4c36aa5e973106eca69e31684..35b928ecb37a05f51135bf34ece53d0ecbd3a07b 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Repository.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Repository.php @@ -107,10 +107,8 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface /** * {@inheritdoc} */ - public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem) + public function deleteById($cartId, $itemId) { - $cartId = $cartItem->getQuoteId(); - $itemId = $cartItem->getItemId(); /** * Quote. * @@ -129,18 +127,7 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface } catch (\Exception $e) { throw new CouldNotSaveException(__('Could not remove item from quote')); } - } - - /** - * {@inheritdoc} - */ - public function deleteById($cartId, $itemId) - { - $item = $this->itemDataFactory->create() - ->setQuoteId($cartId) - ->setItemId($itemId); - $this->delete($item); return true; } diff --git a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php index 37b54ee80106c5a664c82cbdf44d8345c27e4919..9535e3c1c7455e063d9fa7770e48e15616ede6a0 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php @@ -130,15 +130,4 @@ class GuestCartItemRepositoryTest extends \PHPUnit_Framework_TestCase ->willReturn(true); $this->assertTrue($this->guestCartItemRepository->deleteById($this->maskedCartId, $itemId)); } - - /** - * @return void - */ - public function testDelete() - { - $this->cartItemRepositoryMock->expects($this->once()) - ->method('delete') - ->with($this->quoteItemMock); - $this->guestCartItemRepository->delete($this->quoteItemMock); - } } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php index 754c1bd1e467dd877a0b32ea9c41c48ba8b79c3c..9081537f2790e8389100a5e3c4549e3578cc0222 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php @@ -7,7 +7,7 @@ namespace Magento\Quote\Test\Unit\Model\Quote\Item; -use \Magento\Quote\Model\Quote\Item\Repository; +use Magento\Quote\Model\Quote\Item\Repository; class RepositoryTest extends \PHPUnit_Framework_TestCase { @@ -292,15 +292,13 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase { $cartId = 11; $itemId = 5; - $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); - $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) ->method('getItemById')->with($itemId)->will($this->returnValue(false)); $this->quoteMock->expects($this->never())->method('removeItem'); - $this->repository->delete($this->dataMock); + $this->repository->deleteById($cartId, $itemId); } /** @@ -312,8 +310,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase { $cartId = 11; $itemId = 5; - $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); - $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) @@ -328,27 +324,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->with($this->quoteMock) ->willThrowException($exception); - $this->repository->delete($this->dataMock); - } - - /** - * @return void - */ - public function testDelete() - { - $cartId = 11; - $itemId = 5; - $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); - $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); - $this->quoteRepositoryMock->expects($this->once()) - ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); - $this->quoteMock->expects($this->once()) - ->method('getItemById')->with($itemId)->will($this->returnValue($this->quoteItemMock)); - $this->quoteMock->expects($this->once())->method('removeItem'); - $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); - $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock); - - $this->repository->delete($this->dataMock); + $this->repository->deleteById($cartId, $itemId); } /** @@ -363,13 +339,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->with($customerId) ->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getId')->willReturn($cartId); - $this->itemDataFactoryMock->expects($this->once())->method('create')->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('setQuoteId') - ->with($cartId)->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('setItemId') - ->with($itemId)->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); - $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once()) @@ -424,13 +393,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase { $cartId = 11; $itemId = 5; - $this->itemDataFactoryMock->expects($this->once())->method('create')->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('setQuoteId') - ->with($cartId)->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('setItemId') - ->with($itemId)->willReturn($this->dataMock); - $this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); - $this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())