Skip to content

Commit 7d0e8a0

Browse files
author
Cari Spruiell
committed
MAGETWO-36376: Magento\Quote\Api\GuestCartItemRepository
- removed delete methods from non-guest versions CartItemRepositoryInterface and Repository
1 parent 0023d11 commit 7d0e8a0

File tree

4 files changed

+4
-75
lines changed

4 files changed

+4
-75
lines changed

app/code/Magento/Quote/Api/CartItemRepositoryInterface.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ public function getList($cartId);
2727
*/
2828
public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
2929

30-
/**
31-
* Delete cart item
32-
*
33-
* @param \Magento\Quote\Api\Data\CartItemInterface $cartItem
34-
* @return void
35-
* @throws \Magento\Framework\Exception\CouldNotSaveException
36-
*/
37-
public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem);
38-
3930
/**
4031
* Removes the specified item from the specified cart.
4132
*

app/code/Magento/Quote/Model/Quote/Item/Repository.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ public function save(\Magento\Quote\Api\Data\CartItemInterface $cartItem)
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem)
110+
public function deleteById($cartId, $itemId)
111111
{
112-
$cartId = $cartItem->getQuoteId();
113-
$itemId = $cartItem->getItemId();
114112
/**
115113
* Quote.
116114
*
@@ -129,18 +127,7 @@ public function delete(\Magento\Quote\Api\Data\CartItemInterface $cartItem)
129127
} catch (\Exception $e) {
130128
throw new CouldNotSaveException(__('Could not remove item from quote'));
131129
}
132-
}
133-
134-
/**
135-
* {@inheritdoc}
136-
*/
137-
public function deleteById($cartId, $itemId)
138-
{
139-
$item = $this->itemDataFactory->create()
140-
->setQuoteId($cartId)
141-
->setItemId($itemId);
142130

143-
$this->delete($item);
144131
return true;
145132
}
146133

app/code/Magento/Quote/Test/Unit/Model/GuestCart/GuestCartItemRepositoryTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,4 @@ public function testDeleteById()
130130
->willReturn(true);
131131
$this->assertTrue($this->guestCartItemRepository->deleteById($this->maskedCartId, $itemId));
132132
}
133-
134-
/**
135-
* @return void
136-
*/
137-
public function testDelete()
138-
{
139-
$this->cartItemRepositoryMock->expects($this->once())
140-
->method('delete')
141-
->with($this->quoteItemMock);
142-
$this->guestCartItemRepository->delete($this->quoteItemMock);
143-
}
144133
}

app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\Quote\Test\Unit\Model\Quote\Item;
99

10-
use \Magento\Quote\Model\Quote\Item\Repository;
10+
use Magento\Quote\Model\Quote\Item\Repository;
1111

1212
class RepositoryTest extends \PHPUnit_Framework_TestCase
1313
{
@@ -292,15 +292,13 @@ public function testDeleteWithInvalidQuoteItem()
292292
{
293293
$cartId = 11;
294294
$itemId = 5;
295-
$this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId);
296-
$this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId);
297295
$this->quoteRepositoryMock->expects($this->once())
298296
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
299297
$this->quoteMock->expects($this->once())
300298
->method('getItemById')->with($itemId)->will($this->returnValue(false));
301299
$this->quoteMock->expects($this->never())->method('removeItem');
302300

303-
$this->repository->delete($this->dataMock);
301+
$this->repository->deleteById($cartId, $itemId);
304302
}
305303

306304
/**
@@ -312,8 +310,6 @@ public function testDeleteWithCouldNotSaveException()
312310
{
313311
$cartId = 11;
314312
$itemId = 5;
315-
$this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId);
316-
$this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId);
317313
$this->quoteRepositoryMock->expects($this->once())
318314
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
319315
$this->quoteMock->expects($this->once())
@@ -328,27 +324,7 @@ public function testDeleteWithCouldNotSaveException()
328324
->with($this->quoteMock)
329325
->willThrowException($exception);
330326

331-
$this->repository->delete($this->dataMock);
332-
}
333-
334-
/**
335-
* @return void
336-
*/
337-
public function testDelete()
338-
{
339-
$cartId = 11;
340-
$itemId = 5;
341-
$this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId);
342-
$this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId);
343-
$this->quoteRepositoryMock->expects($this->once())
344-
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
345-
$this->quoteMock->expects($this->once())
346-
->method('getItemById')->with($itemId)->will($this->returnValue($this->quoteItemMock));
347-
$this->quoteMock->expects($this->once())->method('removeItem');
348-
$this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
349-
$this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock);
350-
351-
$this->repository->delete($this->dataMock);
327+
$this->repository->deleteById($cartId, $itemId);
352328
}
353329

354330
/**
@@ -363,13 +339,6 @@ public function testDeleteByIdForCustomer()
363339
->with($customerId)
364340
->will($this->returnValue($this->quoteMock));
365341
$this->quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
366-
$this->itemDataFactoryMock->expects($this->once())->method('create')->willReturn($this->dataMock);
367-
$this->dataMock->expects($this->once())->method('setQuoteId')
368-
->with($cartId)->willReturn($this->dataMock);
369-
$this->dataMock->expects($this->once())->method('setItemId')
370-
->with($itemId)->willReturn($this->dataMock);
371-
$this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId);
372-
$this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId);
373342
$this->quoteRepositoryMock->expects($this->once())
374343
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
375344
$this->quoteMock->expects($this->once())
@@ -424,13 +393,6 @@ public function testDeleteById()
424393
{
425394
$cartId = 11;
426395
$itemId = 5;
427-
$this->itemDataFactoryMock->expects($this->once())->method('create')->willReturn($this->dataMock);
428-
$this->dataMock->expects($this->once())->method('setQuoteId')
429-
->with($cartId)->willReturn($this->dataMock);
430-
$this->dataMock->expects($this->once())->method('setItemId')
431-
->with($itemId)->willReturn($this->dataMock);
432-
$this->dataMock->expects($this->once())->method('getQuoteId')->willReturn($cartId);
433-
$this->dataMock->expects($this->once())->method('getItemId')->willReturn($itemId);
434396
$this->quoteRepositoryMock->expects($this->once())
435397
->method('getActive')->with($cartId)->will($this->returnValue($this->quoteMock));
436398
$this->quoteMock->expects($this->once())

0 commit comments

Comments
 (0)