Skip to content

Commit b9ab1ea

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1836 from magento-engcom/2.2-develop-prs
[EngCom] Public Pull Requests - 2.2-develop Public Pull Requests - magento-engcom#980 10123: Wrong invoice entity_model in table eav_entity_type. by @nmalevanec - magento-engcom#964 8507: There is invalid type in PHPDoc block of \Magento\Framework\Data\Tree::getNodeById() by @RomaKis - #11702 Fix getReservedOrderId() to use current store instead of default store by @tdgroot Fixed Public Issues - #10123 Invoice entity_model in table eav_entity_type - #8507 There is invalid type in PHPDoc block of \Magento\Framework\Data\Tree::getNodeById() - #9055 Default Store is always used when retrieving sequence value's for sales entity's.
2 parents 5f763a9 + c027c65 commit b9ab1ea

File tree

7 files changed

+139
-17
lines changed

7 files changed

+139
-17
lines changed

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function getReservedOrderId($quote)
167167
{
168168
return $this->sequenceManager->getSequence(
169169
\Magento\Sales\Model\Order::ENTITY,
170-
$quote->getStore()->getGroup()->getDefaultStoreId()
170+
$quote->getStoreId()
171171
)
172172
->getNextValue();
173173
}
@@ -211,7 +211,7 @@ public function markQuotesRecollectOnCatalogRules()
211211
* @param \Magento\Catalog\Model\Product $product
212212
* @return $this
213213
*/
214-
public function substractProductFromQuotes($product)
214+
public function subtractProductFromQuotes($product)
215215
{
216216
$productId = (int)$product->getId();
217217
if (!$productId) {
@@ -251,6 +251,21 @@ public function substractProductFromQuotes($product)
251251
return $this;
252252
}
253253

254+
/**
255+
* Subtract product from all quotes quantities
256+
*
257+
* @param \Magento\Catalog\Model\Product $product
258+
*
259+
* @deprecated 101.0.1
260+
* @see \Magento\Quote\Model\ResourceModel\Quote::subtractProductFromQuotes
261+
*
262+
* @return $this
263+
*/
264+
public function substractProductFromQuotes($product)
265+
{
266+
return $this->subtractProductFromQuotes($product);
267+
}
268+
254269
/**
255270
* Mark recollect contain product(s) quotes
256271
*
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Quote\Test\Unit\Model\ResourceModel;
8+
9+
use Magento\Framework\DB\Sequence\SequenceInterface;
10+
use Magento\Framework\Model\ResourceModel\Db\Context;
11+
use Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite;
12+
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;
13+
use Magento\Quote\Model\Quote;
14+
use Magento\SalesSequence\Model\Manager;
15+
16+
class QuoteTest extends \PHPUnit\Framework\TestCase
17+
{
18+
/**
19+
* @var Quote|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $quoteMock;
22+
23+
/**
24+
* @var Manager|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $sequenceManagerMock;
27+
28+
/**
29+
* @var SequenceInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $sequenceMock;
32+
33+
/**
34+
* @var \Magento\Quote\Model\ResourceModel\Quote
35+
*/
36+
private $quote;
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protected function setUp()
42+
{
43+
$context = $this->getMockBuilder(Context::class)
44+
->disableOriginalConstructor()
45+
->getMock();
46+
$snapshot = $this->getMockBuilder(Snapshot::class)
47+
->disableOriginalConstructor()
48+
->getMock();
49+
$relationComposite = $this->getMockBuilder(RelationComposite::class)
50+
->disableOriginalConstructor()
51+
->getMock();
52+
$this->quoteMock = $this->getMockBuilder(Quote::class)
53+
->disableOriginalConstructor()
54+
->getMock();
55+
$this->sequenceManagerMock = $this->getMockBuilder(Manager::class)
56+
->disableOriginalConstructor()
57+
->getMock();
58+
$this->sequenceMock = $this->getMockBuilder(SequenceInterface::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
$this->quote = new \Magento\Quote\Model\ResourceModel\Quote(
62+
$context,
63+
$snapshot,
64+
$relationComposite,
65+
$this->sequenceManagerMock,
66+
null
67+
);
68+
}
69+
70+
/**
71+
* @param $entityType
72+
* @param $storeId
73+
* @param $reservedOrderId
74+
* @dataProvider getReservedOrderIdDataProvider
75+
*/
76+
public function testGetReservedOrderId($entityType, $storeId, $reservedOrderId)
77+
{
78+
$this->sequenceManagerMock->expects($this->once())
79+
->method('getSequence')
80+
->with($entityType, $storeId)
81+
->willReturn($this->sequenceMock);
82+
$this->quoteMock->expects($this->once())
83+
->method('getStoreId')
84+
->willReturn($storeId);
85+
$this->sequenceMock->expects($this->once())
86+
->method('getNextValue')
87+
->willReturn($reservedOrderId);
88+
89+
$this->assertEquals($reservedOrderId, $this->quote->getReservedOrderId($this->quoteMock));
90+
}
91+
92+
/**
93+
* @return array
94+
*/
95+
public function getReservedOrderIdDataProvider(): array
96+
{
97+
return [
98+
[\Magento\Sales\Model\Order::ENTITY, 1, '1000000001'],
99+
[\Magento\Sales\Model\Order::ENTITY, 2, '2000000001'],
100+
[\Magento\Sales\Model\Order::ENTITY, 3, '3000000001']
101+
];
102+
}
103+
}

app/code/Magento/Sales/Observer/Backend/SubtractQtyFromQuotesObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function __construct(\Magento\Quote\Model\ResourceModel\Quote $quote)
3131
public function execute(\Magento\Framework\Event\Observer $observer)
3232
{
3333
$product = $observer->getEvent()->getProduct();
34-
$this->_quote->substractProductFromQuotes($product);
34+
$this->_quote->subtractProductFromQuotes($product);
3535
}
3636
}

app/code/Magento/Sales/Setup/UpgradeData.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
108108
[$setup]
109109
);
110110
}
111+
if (version_compare($context->getVersion(), '2.0.9', '<')) {
112+
//Correct wrong source model for "invoice" entity type, introduced by mistake in 2.0.1 upgrade.
113+
$salesSetup->updateEntityType(
114+
'invoice',
115+
'entity_model',
116+
\Magento\Sales\Model\ResourceModel\Order\Invoice::class
117+
);
118+
}
111119
$this->eavConfig->clear();
112120
}
113121

app/code/Magento/Sales/Test/Unit/Observer/Backend/SubtractQtyFromQuotesObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class SubtractQtyFromQuotesObserverTest extends \PHPUnit\Framework\TestCase
1515
protected $_model;
1616

1717
/**
18-
* @var \PHPUnit_Framework_MockObject_MockObject
18+
* @var \Magento\Quote\Model\ResourceModel\Quote|\PHPUnit_Framework_MockObject_MockObject
1919
*/
2020
protected $_quoteMock;
2121

2222
/**
23-
* @var \PHPUnit_Framework_MockObject_MockObject
23+
* @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject
2424
*/
2525
protected $_observerMock;
2626

@@ -48,7 +48,7 @@ public function testSubtractQtyFromQuotes()
4848
['getId', 'getStatus', '__wakeup']
4949
);
5050
$this->_eventMock->expects($this->once())->method('getProduct')->will($this->returnValue($productMock));
51-
$this->_quoteMock->expects($this->once())->method('substractProductFromQuotes')->with($productMock);
51+
$this->_quoteMock->expects($this->once())->method('subtractProductFromQuotes')->with($productMock);
5252
$this->_model->execute($this->_observerMock);
5353
}
5454
}

app/code/Magento/Sales/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Sales" setup_version="2.0.8">
9+
<module name="Magento_Sales" setup_version="2.0.9">
1010
<sequence>
1111
<module name="Magento_Rule"/>
1212
<module name="Magento_Catalog"/>

lib/internal/Magento/Framework/Data/Tree.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ class Tree
2323
*/
2424
protected $_nodes;
2525

26-
/**
27-
* Enter description here...
28-
*
29-
*/
3026
public function __construct()
3127
{
3228
$this->_nodes = new NodeCollection($this);
3329
}
3430

3531
/**
36-
* Enter description here...
32+
* Get Tree.
3733
*
3834
* @return \Magento\Framework\Data\Tree
3935
*/
@@ -43,7 +39,7 @@ public function getTree()
4339
}
4440

4541
/**
46-
* Enter description here...
42+
* Load Tree.
4743
*
4844
* @param Node $parentNode
4945
* @return void
@@ -54,7 +50,7 @@ public function load($parentNode = null)
5450
}
5551

5652
/**
57-
* Enter description here...
53+
* Load Node by Node id.
5854
*
5955
* @param int|string $nodeId
6056
* @return void
@@ -177,7 +173,7 @@ public function getChildren($node)
177173
}
178174

179175
/**
180-
* Enter description here...
176+
* Get Nodes.
181177
*
182178
* @return NodeCollection
183179
*/
@@ -187,9 +183,9 @@ public function getNodes()
187183
}
188184

189185
/**
190-
* Enter description here...
186+
* Get Node by id.
191187
*
192-
* @param Node $nodeId
188+
* @param string|int $nodeId
193189
* @return Node
194190
*/
195191
public function getNodeById($nodeId)

0 commit comments

Comments
 (0)