Skip to content

Commit 4126ffc

Browse files
authored
Merge pull request #3460 from magento-borg/BugFixPR
[2.3-develop] Bug Fixes
2 parents 6fc726b + ca58e8d commit 4126ffc

File tree

15 files changed

+125
-33
lines changed

15 files changed

+125
-33
lines changed

app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@
8484
<argument name="total"/>
8585
</arguments>
8686
<seeInCurrentUrl url="{{CheckoutCartPage.url}}" stepKey="assertUrl"/>
87-
<waitForPageLoad stepKey="waitPageFullyLoaded"/>
88-
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
89-
<waitForText userInput="${{total}}" selector="{{CheckoutCartSummarySection.total}}" time="30" stepKey="waitForTotal"/>
87+
<waitForPageLoad stepKey="waitForCartPage"/>
88+
<conditionalClick selector="{{CheckoutCartSummarySection.shippingHeading}}" dependentSelector="{{CheckoutCartSummarySection.shippingMethodForm}}" visible="false" stepKey="openEstimateShippingSection"/>
89+
<waitForElementVisible selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="waitForShippingSection"/>
90+
<checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectShippingMethod"/>
9091
<see userInput="${{subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/>
9192
<see userInput="({{shippingMethod}})" selector="{{CheckoutCartSummarySection.shippingMethod}}" stepKey="assertShippingMethod"/>
9293
<waitForText userInput="${{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" time="30" stepKey="assertShipping"/>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="CheckoutCartSummarySection">
1212
<element name="subtotal" type="text" selector="//*[@id='cart-totals']//tr[@class='totals sub']//td//span[@class='price']"/>
13+
<element name="shippingMethodForm" type="text" selector="#co-shipping-method-form"/>
1314
<element name="shippingMethod" type="text" selector="//*[@id='cart-totals']//tr[@class='totals shipping excl']//th//span[@class='value']"/>
1415
<element name="shipping" type="text" selector="//*[@id='cart-totals']//tr[@class='totals shipping excl']//td//span[@class='price']"/>
1516
<element name="total" type="text" selector="//*[@id='cart-totals']//tr[@class='grand totals']//td//span[@class='price']"/>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="firstShippingMethod" type="radio" selector="//*[@id='checkout-shipping-method-load']//input[@class='radio']"/>
1414
<element name="shippingMethodRow" type="text" selector=".form.methods-shipping table tbody tr"/>
1515
<element name="checkShippingMethodByName" type="radio" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//input" parameterized="true"/>
16+
<element name="shippingMethodFlatRate" type="radio" selector="#checkout-shipping-method-load input[value='flatrate_flatrate']"/>
1617
<element name="shippingMethodRowByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/.." parameterized="true"/>
1718
<element name="shipHereButton" type="button" selector="//div/following-sibling::div/button[contains(@class, 'action-select-shipping-item')]"/>
1819
<element name="shippingMethodLoader" type="button" selector="//div[contains(@class, 'checkout-shipping-method')]/following-sibling::div[contains(@class, 'loading-mask')]"/>

app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
<element name="AddParam" type="button" selector=".rule-param-add"/>
9999
<element name="ConditionsDropdown" type="select" selector="#conditions__1__new_child"/>
100100
<element name="RuleParam" type="button" selector="//a[text()='...']"/>
101+
<element name="RuleParamSelect" type="select" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//select" parameterized="true"/>
102+
<element name="RuleParamInput" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//input" parameterized="true"/>
103+
<element name="RuleParamLabel" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//a" parameterized="true"/>
101104
<element name="Chooser" type="button" selector="//img[@title='Open Chooser']"/>
102105
<element name="PageSize" type="input" selector="input[name='parameters[page_size]']"/>
103106
<element name="ProductAttribute" type="multiselect" selector="select[name='parameters[show_attributes][]']" />

app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,29 @@
5757
<click selector="{{WidgetSection.RuleParam}}" stepKey="clickRuleParam" />
5858
<waitForElementVisible selector="{{WidgetSection.Chooser}}" stepKey="waitForElement" />
5959
<click selector="{{WidgetSection.Chooser}}" stepKey="clickChooser" />
60-
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear3" />
60+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear4" />
6161
<click selector="{{WidgetSection.PreCreateCategory('$$createPreReqCategory.name$$')}}" stepKey="selectPreCategory" />
62+
63+
<!-- Test that the "<" operand functions correctly -->
64+
<click selector="{{WidgetSection.AddParam}}" stepKey="clickAddParamBtn2" />
65+
<waitForElementVisible selector="{{WidgetSection.ConditionsDropdown}}" stepKey="waitForDropdownVisible2"/>
66+
<selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="Price" stepKey="selectPriceCondition"/>
67+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear3"/>
68+
<click selector="{{WidgetSection.RuleParamLabel('2','1')}}" stepKey="clickOperatorLabel"/>
69+
<selectOption selector="{{WidgetSection.RuleParamSelect('2','1')}}" userInput="&lt;" stepKey="selectLessThanCondition"/>
70+
<click selector="{{WidgetSection.RuleParam}}" stepKey="clickRuleParam2"/>
71+
<fillField selector="{{WidgetSection.RuleParamInput('2','2')}}" userInput="125" stepKey="fillMaxPrice"/>
72+
73+
<!-- Test that the ">" operand functions correctly -->
74+
<click selector="{{WidgetSection.AddParam}}" stepKey="clickAddParamBtn3" />
75+
<waitForElementVisible selector="{{WidgetSection.ConditionsDropdown}}" stepKey="waitForDropdownVisible3"/>
76+
<selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="Price" stepKey="selectPriceCondition2"/>
77+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear5"/>
78+
<click selector="{{WidgetSection.RuleParamLabel('3','1')}}" stepKey="clickOperatorLabel2"/>
79+
<selectOption selector="{{WidgetSection.RuleParamSelect('3','1')}}" userInput="&gt;" stepKey="selectLessThanCondition2"/>
80+
<click selector="{{WidgetSection.RuleParam}}" stepKey="clickRuleParam3"/>
81+
<fillField selector="{{WidgetSection.RuleParamInput('3','2')}}" userInput="1" stepKey="fillMinPrice"/>
82+
6283
<click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidget" />
6384
<waitForPageLoad stepKey="wait6" />
6485
<scrollTo selector="{{CmsNewPagePageSeoSection.header}}" stepKey="scrollToSearchEngineTab" />

app/code/Magento/Sales/Model/Order/Creditmemo/Item/Validation/CreationQuantityValidator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CreationQuantityValidator implements ValidatorInterface
3030

3131
/**
3232
* ItemCreationQuantityValidator constructor.
33+
*
3334
* @param OrderItemRepositoryInterface $orderItemRepository
3435
* @param mixed $context
3536
*/
@@ -53,6 +54,10 @@ public function validate($entity)
5354
return [__('The creditmemo contains product item that is not part of the original order.')];
5455
}
5556

57+
if ($orderItem->isDummy()) {
58+
return [__('The creditmemo contains incorrect product items.')];
59+
}
60+
5661
if (!$this->isQtyAvailable($orderItem, $entity->getQty())) {
5762
return [__('The quantity to refund must not be greater than the unrefunded quantity.')];
5863
}
@@ -61,6 +66,8 @@ public function validate($entity)
6166
}
6267

6368
/**
69+
* Check the quantity to refund is greater than the unrefunded quantity
70+
*
6471
* @param Item $orderItem
6572
* @param int $qty
6673
* @return bool
@@ -71,6 +78,8 @@ private function isQtyAvailable(Item $orderItem, $qty)
7178
}
7279

7380
/**
81+
* Check to see if Item is part of the order
82+
*
7483
* @param OrderItemInterface $orderItem
7584
* @return bool
7685
*/

app/code/Magento/Sales/Model/Order/ItemRepository.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function __construct(
9595
}
9696

9797
/**
98-
* load entity
98+
* Load entity
9999
*
100100
* @param int $id
101101
* @return OrderItemInterface
@@ -228,6 +228,14 @@ private function addParentItem(OrderItemInterface $orderItem)
228228
{
229229
if ($parentId = $orderItem->getParentItemId()) {
230230
$orderItem->setParentItem($this->get($parentId));
231+
} else {
232+
$orderCollection = $orderItem->getOrder()->getItemsCollection()->filterByParent($orderItem->getItemId());
233+
234+
foreach ($orderCollection->getItems() as $item) {
235+
if ($item->getParentItemId() === $orderItem->getItemId()) {
236+
$item->setParentItem($orderItem);
237+
}
238+
}
231239
}
232240
}
233241

app/code/Magento/Sales/Test/Unit/Model/Order/ItemRepositoryTest.php

Lines changed: 65 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function testGetEmptyEntity()
145145
$model->get($orderItemId);
146146
}
147147

148-
public function testGet()
148+
public function testGetAsParentWithChild()
149149
{
150150
$orderItemId = 1;
151151
$productType = 'configurable';
@@ -154,7 +154,55 @@ public function testGet()
154154

155155
$this->getProductOptionExtensionMock();
156156
$productOption = $this->getProductOptionMock();
157-
$orderItemMock = $this->getOrderMock($productType, $productOption);
157+
$orderItemMock = $this->getOrderItemMock($productType, $productOption);
158+
159+
$orderItemCollectionMock = $this->createMock(\Magento\Sales\Model\ResourceModel\Order\Item\Collection::class);
160+
$orderItemCollectionMock->expects($this->once())
161+
->method('filterByParent')
162+
->with($orderItemId)
163+
->willReturnSelf();
164+
$orderItemCollectionMock->expects($this->once())
165+
->method('getItems')
166+
->willReturn([$orderItemMock]);
167+
168+
$orderMock = $this->createMock(\Magento\Sales\Model\Order::class);
169+
$orderMock->expects($this->once())
170+
->method('getItemsCollection')
171+
->willReturn($orderItemCollectionMock);
172+
173+
$orderItemMock->expects($this->once())
174+
->method('load')
175+
->with($orderItemId)
176+
->willReturn($orderItemMock);
177+
$orderItemMock->expects($this->exactly(3))
178+
->method('getItemId')
179+
->willReturn($orderItemId);
180+
$orderItemMock->expects($this->once())
181+
->method('getOrder')
182+
->willReturn($orderMock);
183+
184+
$this->metadata->expects($this->once())
185+
->method('getNewInstance')
186+
->willReturn($orderItemMock);
187+
188+
$model = $this->getModel($orderItemMock, $productType);
189+
$this->assertSame($orderItemMock, $model->get($orderItemId));
190+
191+
// Assert already registered
192+
$this->assertSame($orderItemMock, $model->get($orderItemId));
193+
}
194+
195+
public function testGetAsChild()
196+
{
197+
$orderItemId = 1;
198+
$parentItemId = 66;
199+
$productType = 'configurable';
200+
201+
$this->productOptionData = ['option1' => 'value1'];
202+
203+
$this->getProductOptionExtensionMock();
204+
$productOption = $this->getProductOptionMock();
205+
$orderItemMock = $this->getOrderItemMock($productType, $productOption);
158206

159207
$orderItemMock->expects($this->once())
160208
->method('load')
@@ -163,12 +211,20 @@ public function testGet()
163211
$orderItemMock->expects($this->once())
164212
->method('getItemId')
165213
->willReturn($orderItemId);
214+
$orderItemMock->expects($this->exactly(3))
215+
->method('getParentItemId')
216+
->willReturn($parentItemId);
166217

167218
$this->metadata->expects($this->once())
168219
->method('getNewInstance')
169220
->willReturn($orderItemMock);
170221

222+
$parentItemMock = $this->createMock(\Magento\Sales\Model\Order\Item::class);
223+
171224
$model = $this->getModel($orderItemMock, $productType);
225+
$reflectedRegistryProperty = new \ReflectionProperty($model, 'registry');
226+
$reflectedRegistryProperty->setAccessible(true);
227+
$reflectedRegistryProperty->setValue($model, [$parentItemId => $parentItemMock]);
172228
$this->assertSame($orderItemMock, $model->get($orderItemId));
173229

174230
// Assert already registered
@@ -184,7 +240,7 @@ public function testGetList()
184240
->getMock();
185241
$this->getProductOptionExtensionMock();
186242
$productOption = $this->getProductOptionMock();
187-
$orderItemMock = $this->getOrderMock($productType, $productOption);
243+
$orderItemMock = $this->getOrderItemMock($productType, $productOption);
188244

189245
$searchResultMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Item\Collection::class)
190246
->disableOriginalConstructor()
@@ -206,26 +262,12 @@ public function testDeleteById()
206262
$orderItemId = 1;
207263
$productType = 'configurable';
208264

209-
$requestMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
210-
->disableOriginalConstructor()
211-
->getMock();
212-
213265
$orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
214266
->disableOriginalConstructor()
215267
->getMock();
216268
$orderItemMock->expects($this->once())
217-
->method('load')
218-
->with($orderItemId)
219-
->willReturn($orderItemMock);
220-
$orderItemMock->expects($this->once())
221-
->method('getItemId')
269+
->method('getEntityId')
222270
->willReturn($orderItemId);
223-
$orderItemMock->expects($this->once())
224-
->method('getProductType')
225-
->willReturn($productType);
226-
$orderItemMock->expects($this->once())
227-
->method('getBuyRequest')
228-
->willReturn($requestMock);
229271

230272
$orderItemResourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class)
231273
->disableOriginalConstructor()
@@ -235,15 +277,16 @@ public function testDeleteById()
235277
->with($orderItemMock)
236278
->willReturnSelf();
237279

238-
$this->metadata->expects($this->once())
239-
->method('getNewInstance')
240-
->willReturn($orderItemMock);
241280
$this->metadata->expects($this->exactly(1))
242281
->method('getMapper')
243282
->willReturn($orderItemResourceMock);
244283

245284
$model = $this->getModel($orderItemMock, $productType);
285+
$reflectedRegistryProperty = new \ReflectionProperty($model, 'registry');
286+
$reflectedRegistryProperty->setAccessible(true);
287+
$reflectedRegistryProperty->setValue($model, [$orderItemId => $orderItemMock]);
246288
$this->assertTrue($model->deleteById($orderItemId));
289+
$this->assertEmpty($reflectedRegistryProperty->getValue($model));
247290
}
248291

249292
/**
@@ -301,7 +344,7 @@ protected function getModel(
301344
* @param \PHPUnit_Framework_MockObject_MockObject $productOption
302345
* @return \PHPUnit_Framework_MockObject_MockObject
303346
*/
304-
protected function getOrderMock($productType, $productOption)
347+
protected function getOrderItemMock($productType, $productOption)
305348
{
306349
$requestMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
307350
->disableOriginalConstructor()

app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountry.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@
7272
<!-- Should not see the discount yet because we have not set country -->
7373
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
7474
<waitForPageLoad stepKey="waitForCartPage"/>
75+
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/>
76+
<checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/>
7577
<see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/>
7678
<dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/>
7779

7880
<!-- See discount if we use valid country -->
79-
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/>
8081
<selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="Brazil" stepKey="fillCountry"/>
8182
<waitForPageLoad stepKey="waitForCountry1"/>
8283
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>

app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcode.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@
7676
<!-- Should not see the discount yet because we have not filled in postcode -->
7777
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
7878
<waitForPageLoad stepKey="waitForCartPage"/>
79+
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/>
80+
<checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/>
7981
<see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/>
8082
<dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/>
8183

8284
<!-- See discount if we use valid postcode -->
83-
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/>
8485
<fillField selector="{{CheckoutCartSummarySection.postcode}}" userInput="78613" stepKey="fillPostcode"/>
8586
<waitForPageLoad stepKey="waitForPostcode1"/>
8687
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>

app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleState.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@
7272
<!-- Should not see the discount yet because we have not filled in postcode -->
7373
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
7474
<waitForPageLoad stepKey="waitForCartPage"/>
75+
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/>
76+
<checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/>
7577
<see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/>
7678
<dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/>
7779

7880
<!-- See discount if we use valid postcode -->
79-
<click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/>
8081
<selectOption selector="{{CheckoutCartSummarySection.stateProvince}}" userInput="Indiana" stepKey="fillState"/>
8182
<waitForPageLoad stepKey="waitForPostcode1"/>
8283
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>

dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplyCatalogPriceRulesTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
<data name="productPrice/0/special" xsi:type="string">5</data>
107107
<data name="productPrice/0/sub_total" xsi:type="string">5</data>
108108
<data name="productPrice/0/regular" xsi:type="string">10</data>
109+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
110+
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
109111
<constraint name="Magento\CatalogRule\Test\Constraint\AssertCatalogPriceRuleNotAppliedCatalogPage" />
110112
<constraint name="Magento\CatalogRule\Test\Constraint\AssertCatalogPriceRuleNotAppliedProductPage" />
111113
<constraint name="Magento\CatalogRule\Test\Constraint\AssertCatalogPriceRuleNotAppliedShoppingCart" />

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Shipping/Method.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function () {
6767
*/
6868
private function waitFormLoading()
6969
{
70-
$this->_rootElement->click();
7170
$this->browser->waitUntil(
7271
function () {
7372
return $this->browser->find($this->waitElement)->isVisible() ? null : true;

0 commit comments

Comments
 (0)