Skip to content

Commit 9a5fc02

Browse files
committed
MAGETWO-31559: [TD] Removing NominalItems usage
- add tests
1 parent 4fbb799 commit 9a5fc02

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,4 +1052,33 @@ public function testGetPaymentIsDeleted()
10521052

10531053
$this->assertInstanceOf('\Magento\Sales\Model\Quote\Payment', $this->quote->getPayment());
10541054
}
1055+
1056+
public function testAddItem()
1057+
{
1058+
$item = $this->getMock('Magento\Sales\Model\Quote\Item', ['setQuote', 'getId'], [], '', false);
1059+
$item->expects($this->once())
1060+
->method('setQuote');
1061+
$item->expects($this->once())
1062+
->method('getId')
1063+
->willReturn(false);
1064+
$itemsMock = $this->getMock(
1065+
'Magento\Eav\Model\Entity\Collection\AbstractCollection',
1066+
['setQuote', 'addItem'],
1067+
[],
1068+
'',
1069+
false
1070+
);
1071+
$itemsMock->expects($this->once())
1072+
->method('setQuote');
1073+
$itemsMock->expects($this->once())
1074+
->method('addItem')
1075+
->with($item);
1076+
$this->quoteItemCollectionFactoryMock->expects($this->once())
1077+
->method('create')
1078+
->willReturn($itemsMock);
1079+
$this->eventManagerMock->expects($this->once())
1080+
->method('dispatch');
1081+
1082+
$this->quote->addItem($item);
1083+
}
10551084
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
4+
*/
5+
namespace Magento\Sales\Model\Service;
6+
7+
use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
8+
9+
/**
10+
* Class QuoteTest
11+
*/
12+
class QuoteTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var \Magento\Sales\Model\Service\Quote
16+
*/
17+
protected $quoteService;
18+
19+
/**
20+
* @var \PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
protected $quoteMock;
23+
24+
protected function setUp()
25+
{
26+
$objectManager = new ObjectManagerHelper($this);
27+
$convertFactory = $this->getMock('Magento\Sales\Model\Convert\QuoteFactory', ['create'], [], '', false);
28+
$convertFactory->expects($this->once())
29+
->method('create');
30+
$this->quoteMock = $this->getMock(
31+
'Magento\Sales\Model\Quote',
32+
['getAllVisibleItems', 'setIsActive'],
33+
[],
34+
'',
35+
false
36+
);
37+
$this->quoteService = $objectManager->getObject(
38+
'Magento\Sales\Model\Service\Quote',
39+
['quote' => $this->quoteMock, 'convertQuoteFactory' => $convertFactory]
40+
);
41+
}
42+
43+
public function testSubmitAllWithDataObject()
44+
{
45+
$this->quoteMock->expects($this->once())
46+
->method('getAllVisibleItems')
47+
->willReturn(false);
48+
$this->quoteMock->expects($this->once())
49+
->method('setIsActive');
50+
$this->quoteService->submitAllWithDataObject();
51+
}
52+
}

0 commit comments

Comments
 (0)