diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote.php b/app/code/Magento/Quote/Model/ResourceModel/Quote.php index 4ab0c803c879c..0efbc5145530e 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote.php @@ -167,7 +167,7 @@ public function getReservedOrderId($quote) { return $this->sequenceManager->getSequence( \Magento\Sales\Model\Order::ENTITY, - $quote->getStore()->getStoreId() + $quote->getStoreId() ) ->getNextValue(); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/QuoteTest.php b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/QuoteTest.php index d60dd073d121d..27d113767029d 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/QuoteTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ResourceModel/QuoteTest.php @@ -23,11 +23,6 @@ class QuoteTest extends \PHPUnit\Framework\TestCase */ private $sequenceMock; - /** - * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject - */ - private $storeMock; - /** * @var \Magento\Quote\Model\ResourceModel\Quote */ @@ -56,9 +51,6 @@ protected function setUp() $this->sequenceMock = $this->getMockBuilder(\Magento\Framework\DB\Sequence\SequenceInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->storeMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) - ->disableOriginalConstructor() - ->getMock(); $this->quote = new \Magento\Quote\Model\ResourceModel\Quote( $context, $snapshot, @@ -71,24 +63,23 @@ protected function setUp() /** * @param $entityType * @param $storeId + * @param $reservedOrderId * @dataProvider getReservedOrderIdDataProvider */ - public function testGetReservedOrderId($entityType, $storeId) + public function testGetReservedOrderId($entityType, $storeId, $reservedOrderId) { $this->sequenceManagerMock->expects($this->once()) ->method('getSequence') - ->with(\Magento\Sales\Model\Order::ENTITY, $storeId) + ->with($entityType, $storeId) ->willReturn($this->sequenceMock); $this->quoteMock->expects($this->once()) - ->method('getStore') - ->willReturn($this->storeMock); - $this->storeMock->expects($this->once()) ->method('getStoreId') ->willReturn($storeId); $this->sequenceMock->expects($this->once()) - ->method('getNextValue'); + ->method('getNextValue') + ->willReturn($reservedOrderId); - $this->quote->getReservedOrderId($this->quoteMock); + $this->assertEquals($reservedOrderId, $this->quote->getReservedOrderId($this->quoteMock)); } /** @@ -97,9 +88,9 @@ public function testGetReservedOrderId($entityType, $storeId) public function getReservedOrderIdDataProvider(): array { return [ - [\Magento\Sales\Model\Order::ENTITY, 1], - [\Magento\Sales\Model\Order::ENTITY, 2], - [\Magento\Sales\Model\Order::ENTITY, 3] + [\Magento\Sales\Model\Order::ENTITY, 1, '1000000001'], + [\Magento\Sales\Model\Order::ENTITY, 2, '2000000001'], + [\Magento\Sales\Model\Order::ENTITY, 3, '3000000001'] ]; } } \ No newline at end of file