Skip to content

Commit 5461965

Browse files
committed
MAGETWO-89337: "My Requisition Lists" option is absent in header menu.
1 parent e35fca3 commit 5461965

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

app/code/Magento/Sales/Test/Unit/CustomerData/LastOrderedItemsTest.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class LastOrderedItemsTest extends \PHPUnit\Framework\TestCase
5858
*/
5959
private $section;
6060

61+
/**
62+
* @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
63+
*/
64+
private $loggerMock;
65+
6166
protected function setUp()
6267
{
6368
$this->objectManagerHelper = new ObjectManagerHelper($this);
@@ -81,13 +86,16 @@ protected function setUp()
8186
->getMock();
8287
$this->productRepository = $this->getMockBuilder(\Magento\Catalog\Api\ProductRepositoryInterface::class)
8388
->getMockForAbstractClass();
89+
$this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
90+
->getMockForAbstractClass();
8491
$this->section = new \Magento\Sales\CustomerData\LastOrderedItems(
8592
$this->orderCollectionFactoryMock,
8693
$this->orderConfigMock,
8794
$this->customerSessionMock,
8895
$this->stockRegistryMock,
8996
$this->storeManagerMock,
90-
$this->productRepository
97+
$this->productRepository,
98+
$this->loggerMock
9199
);
92100
}
93101

@@ -196,4 +204,34 @@ private function getLastOrderMock()
196204
->willReturnSelf();
197205
return $this->orderMock;
198206
}
207+
208+
public function testGetSectionDataWithNotExistingProduct()
209+
{
210+
$storeId = 1;
211+
$websiteId = 4;
212+
$productId = 1;
213+
$exception = new \Magento\Framework\Exception\NoSuchEntityException(__("Product doesn't exist"));
214+
$orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
215+
->disableOriginalConstructor()
216+
->setMethods(['getProductId'])
217+
->getMock();
218+
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMockForAbstractClass();
219+
220+
$this->getLastOrderMock();
221+
$this->storeManagerMock->expects($this->exactly(2))->method('getStore')->willReturn($storeMock);
222+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
223+
$storeMock->expects($this->once())->method('getId')->willReturn($storeId);
224+
$this->orderMock->expects($this->once())
225+
->method('getParentItemsRandomCollection')
226+
->with(\Magento\Sales\CustomerData\LastOrderedItems::SIDEBAR_ORDER_LIMIT)
227+
->willReturn([$orderItemMock]);
228+
$orderItemMock->expects($this->once())->method('getProductId')->willReturn($productId);
229+
$this->productRepository->expects($this->once())
230+
->method('getById')
231+
->with($productId, false, $storeId)
232+
->willThrowException($exception);
233+
$this->loggerMock->expects($this->once())->method('critical')->with($exception);
234+
235+
$this->assertEquals(['items' => []], $this->section->getSectionData());
236+
}
199237
}

0 commit comments

Comments
 (0)