Skip to content

Commit

Permalink
Use $quote->getStoreId() in Quote::getReservedOrderId()
Browse files Browse the repository at this point in the history
  • Loading branch information
tdgroot committed Oct 25, 2017
1 parent 5afcc52 commit 6b325e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/ResourceModel/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function getReservedOrderId($quote)
{
return $this->sequenceManager->getSequence(
\Magento\Sales\Model\Order::ENTITY,
$quote->getStore()->getStoreId()
$quote->getStoreId()
)
->getNextValue();
}
Expand Down
27 changes: 9 additions & 18 deletions app/code/Magento/Quote/Test/Unit/Model/ResourceModel/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
Expand All @@ -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));
}

/**
Expand All @@ -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']
];
}
}

0 comments on commit 6b325e1

Please sign in to comment.