Skip to content

Commit c03bde6

Browse files
authored
Merge pull request #6244 from magento-tsg/2.4-develop-pr97
[Arrows] Fixes for 2.4 (pr97) (2.4-develop)
2 parents 32ed03c + a102371 commit c03bde6

File tree

23 files changed

+145
-66
lines changed

23 files changed

+145
-66
lines changed

app/code/Magento/Catalog/Test/Unit/Model/Plugin/ProductRepository/TransactionWrapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function setUp(): void
6262
$this->closureMock = function () use ($productMock) {
6363
return $productMock;
6464
};
65-
$this->rollbackClosureMock = function () use ($productMock) {
65+
$this->rollbackClosureMock = function () {
6666
throw new \Exception(self::ERROR_MSG);
6767
};
6868

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/TierPrices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function resolve(
8787
$this->tiers->addProductFilter($productId);
8888

8989
return $this->valueFactory->create(
90-
function () use ($productId, $context) {
90+
function () use ($productId) {
9191
$tierPrices = $this->tiers->getProductTierPrices($productId);
9292

9393
return $tierPrices ?? [];

app/code/Magento/CatalogSearch/Model/Advanced.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ protected function getPreparedSearchCriteria($attribute, $value)
359359
if (is_array($value)) {
360360
if (isset($value['from']) && isset($value['to'])) {
361361
if (!empty($value['from']) || !empty($value['to'])) {
362+
$from = '';
363+
$to = '';
362364
if (isset($value['currency'])) {
363365
/** @var $currencyModel Currency */
364366
$currencyModel = $this->_currencyFactory->create()->load($value['currency']);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/>
2525
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
2626
<fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
27-
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
27+
<waitForPageLoad stepKey="waitForLoadingMask"/>
2828
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
29-
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
29+
<waitForElementVisible selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
30+
<waitForPageLoad stepKey="waitForShippingLoadingMask"/>
3031
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
31-
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
32+
<waitForElementVisible selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
3233
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
3334
</actionGroup>
3435
</actionGroups>

app/code/Magento/Customer/Controller/Adminhtml/Index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,8 @@ protected function prepareDefaultCustomerTitle(\Magento\Backend\Model\View\Resul
289289
protected function _addSessionErrorMessages($messages)
290290
{
291291
$messages = (array)$messages;
292-
$session = $this->_getSession();
293292

294-
$callback = function ($error) use ($session) {
293+
$callback = function ($error) {
295294
if (!$error instanceof Error) {
296295
$error = new Error($error);
297296
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertStorefrontCustomerHasNoOtherAddressesActionGroup">
11+
<annotations>
12+
<description>Verifies customer has no additional address in address book</description>
13+
</annotations>
14+
<amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/>
15+
<waitForText userInput="You have no other address entries in your address book." selector=".block-addresses-list" stepKey="assertOtherAddresses"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
1313
use Magento\Framework\DataObject;
1414
use PHPUnit\Framework\TestCase;
15-
use Psr\Log\LoggerInterface;
1615

1716
class BillingTest extends TestCase
1817
{
@@ -23,10 +22,7 @@ class BillingTest extends TestCase
2322

2423
protected function setUp(): void
2524
{
26-
$logger = $this->getMockBuilder(LoggerInterface::class)
27-
->getMock();
28-
/** @var LoggerInterface $logger */
29-
$this->testable = new Billing($logger);
25+
$this->testable = new Billing();
3026
}
3127

3228
public function testBeforeSave()

app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
1313
use Magento\Framework\DataObject;
1414
use PHPUnit\Framework\TestCase;
15-
use Psr\Log\LoggerInterface;
1615

1716
class ShippingTest extends TestCase
1817
{
@@ -23,10 +22,7 @@ class ShippingTest extends TestCase
2322

2423
protected function setUp(): void
2524
{
26-
$logger = $this->getMockBuilder(LoggerInterface::class)
27-
->getMock();
28-
/** @var LoggerInterface $logger */
29-
$this->testable = new Shipping($logger);
25+
$this->testable = new Shipping();
3026
}
3127

3228
public function testBeforeSave()

app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected function setUp(): void
6262
$this->closureMock = function () use ($customerMock) {
6363
return $customerMock;
6464
};
65-
$this->rollbackClosureMock = function () use ($customerMock) {
65+
$this->rollbackClosureMock = function () {
6666
throw new \Exception(self::ERROR_MSG);
6767
};
6868

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
550550

551551
$quote = $this->getQuote();
552552
if (!$quote->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
553+
$quote->getBillingAddress()->setCustomerAddressId(
554+
$quote->getShippingAddress()->getCustomerAddressId()
555+
);
553556
$this->setShippingAsBilling(1);
554557
}
555558

@@ -2120,6 +2123,9 @@ private function isAddressesAreEqual(Order $order)
21202123
$billingData['address_type'],
21212124
$billingData['entity_id']
21222125
);
2126+
if (isset($shippingData['customer_address_id']) && !isset($billingData['customer_address_id'])) {
2127+
unset($shippingData['customer_address_id']);
2128+
}
21232129

21242130
return $shippingData == $billingData;
21252131
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminStartReorderFromOrderPageActionGroup">
11+
<annotations>
12+
<description>Reorder existing order. Requires admin order page to be opened.</description>
13+
</annotations>
14+
15+
<click selector="{{AdminOrderDetailsMainActionsSection.reorder}}" stepKey="clickReorder"/>
16+
<waitForPageLoad stepKey="waitPageLoad"/>
17+
<waitForElementVisible selector="{{AdminHeaderSection.pageTitle}}" stepKey="waitForPageTitle"/>
18+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Create New Order" stepKey="seeCreateNewOrderPageTitle"/>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminReorderAddressNotSavedInAddressBookTest">
11+
<annotations>
12+
<features value="Sales"/>
13+
<stories value="Reorder"/>
14+
<title value="Same shipping address is not repeating multiple times in storefront checkout when Reordered"/>
15+
<description value="Same shipping address is not repeating multiple times in storefront checkout when Reordered"/>
16+
<testCaseId value="MC-38412"/>
17+
<useCaseId value="MC-38113"/>
18+
<severity value="MAJOR"/>
19+
<group value="sales"/>
20+
</annotations>
21+
<before>
22+
<createData entity="ApiCategory" stepKey="category"/>
23+
<createData entity="ApiSimpleProduct" stepKey="product">
24+
<requiredEntity createDataKey="category"/>
25+
</createData>
26+
<createData entity="Simple_Customer_Without_Address" stepKey="customer"/>
27+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
28+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount">
29+
<argument name="Customer" value="$customer$"/>
30+
</actionGroup>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="product" stepKey="deleteProduct"/>
34+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
35+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
36+
<deleteData createDataKey="customer" stepKey="deleteCustomer"/>
37+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
38+
</after>
39+
40+
<!-- Create order for registered customer -->
41+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addSimpleProductToOrder">
42+
<argument name="product" value="$product$"/>
43+
</actionGroup>
44+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="openCheckoutPage"/>
45+
<actionGroup ref="LoggedInUserCheckoutFillingShippingSectionActionGroup" stepKey="fillAddressForm"/>
46+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickPlaceOrder"/>
47+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>
48+
49+
<!-- Reorder created order -->
50+
<actionGroup ref="OpenOrderByIdActionGroup" stepKey="openOrderById">
51+
<argument name="orderId" value="{$grabOrderNumber}"/>
52+
</actionGroup>
53+
<actionGroup ref="AdminStartReorderFromOrderPageActionGroup" stepKey="startReorder"/>
54+
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
55+
56+
<!-- Assert no additional addresses saved -->
57+
<actionGroup ref="AssertStorefrontCustomerHasNoOtherAddressesActionGroup" stepKey="assertAddresses"/>
58+
</test>
59+
</tests>

app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ endif; ?>
114114
type="checkbox"
115115
id="<?= $block->escapeHtmlAttr($block->getForm()->getHtmlIdPrefix()) ?>save_in_address_book"
116116
value="1"
117-
<?php if (!$block->getDontSaveInAddressBook()): ?> checked="checked"<?php endif; ?>
117+
<?php if (!$block->getDontSaveInAddressBook() && !$block->getAddressId()): ?>
118+
checked="checked"
119+
<?php endif; ?>
118120
class="admin__control-checkbox"/>
119121
<label for="<?= $block->escapeHtmlAttr($block->getForm()->getHtmlIdPrefix()) ?>save_in_address_book"
120122
class="admin__field-label"><?= $block->escapeHtml(__('Save in address book')) ?></label>

app/code/Magento/Theme/Test/Unit/Block/Adminhtml/Design/Config/Edit/SaveButtonTest.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
namespace Magento\Theme\Test\Unit\Block\Adminhtml\Design\Config\Edit;
99

10-
use Magento\Backend\Block\Widget\Context;
11-
use Magento\Framework\UrlInterface;
1210
use Magento\Theme\Block\Adminhtml\Design\Config\Edit\SaveButton;
13-
use PHPUnit\Framework\MockObject\MockObject;
1411
use PHPUnit\Framework\TestCase;
1512

1613
class SaveButtonTest extends TestCase
@@ -20,16 +17,9 @@ class SaveButtonTest extends TestCase
2017
*/
2118
protected $block;
2219

23-
/**
24-
* @var Context|MockObject
25-
*/
26-
protected $context;
27-
2820
protected function setUp(): void
2921
{
30-
$this->initContext();
31-
32-
$this->block = new SaveButton($this->context);
22+
$this->block = new SaveButton();
3323
}
3424

3525
public function testGetButtonData()
@@ -41,18 +31,4 @@ public function testGetButtonData()
4131
$this->assertArrayHasKey('data_attribute', $result);
4232
$this->assertIsArray($result['data_attribute']);
4333
}
44-
45-
protected function initContext()
46-
{
47-
$this->urlBuilder = $this->getMockBuilder(UrlInterface::class)
48-
->disableOriginalConstructor()
49-
->getMockForAbstractClass();
50-
51-
$this->context = $this->getMockBuilder(Context::class)
52-
->disableOriginalConstructor()
53-
->getMock();
54-
$this->context->expects($this->any())
55-
->method('getUrlBuilder')
56-
->willReturn($this->urlBuilder);
57-
}
5834
}

dev/tests/integration/testsuite/Magento/Swatches/Model/AttributeCreateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function ($values, $index) use ($optionsPerAttribute) {
5252
);
5353
$data['optionvisual']['value'] = array_reduce(
5454
range(1, $optionsPerAttribute),
55-
function ($values, $index) use ($optionsPerAttribute) {
55+
function ($values, $index) {
5656
$values['option_' . $index] = ['option ' . $index];
5757
return $values;
5858
},
@@ -61,7 +61,7 @@ function ($values, $index) use ($optionsPerAttribute) {
6161

6262
$data['options']['option'] = array_reduce(
6363
range(1, $optionsPerAttribute),
64-
function ($values, $index) use ($optionsPerAttribute) {
64+
function ($values, $index) {
6565
$values[] = [
6666
'label' => 'option ' . $index,
6767
'value' => 'option_' . $index

dev/tests/integration/testsuite/Magento/Swatches/Model/SwatchAttributeOptionAddTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testSwatchOptionAdd()
4040

4141
$data['options']['option'] = array_reduce(
4242
range(10, $optionsPerAttribute),
43-
function ($values, $index) use ($optionsPerAttribute) {
43+
function ($values, $index) {
4444
$values[] = [
4545
'label' => 'option ' . $index,
4646
'value' => 'option_' . $index

lib/internal/Magento/Framework/Amqp/Test/Unit/Topology/QueueInstallerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class QueueInstallerTest extends TestCase
1616
{
1717
public function testInstall()
1818
{
19-
$bindingInstaller = $this->getMockForAbstractClass(QueueConfigItemInterface::class);
20-
$model = new QueueInstaller($bindingInstaller);
19+
$model = new QueueInstaller();
2120
$channel = $this->createMock(AMQPChannel::class);
2221

2322
$queue = $this->getMockForAbstractClass(QueueConfigItemInterface::class);

lib/internal/Magento/Framework/Setup/ExternalFKSetup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ protected function execute()
9292
/**
9393
* Get foreign keys for tables and columns
9494
*
95-
* @param string $refTable
96-
* @param string $refColumn
9795
* @param string $targetTable
9896
* @param string $targetColumn
97+
* @param string $refTable
98+
* @param string $refColumn
9999
* @return array
100100
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
101101
*/
@@ -110,7 +110,7 @@ protected function getForeignKeys(
110110
);
111111
$foreignKeys = array_filter(
112112
$foreignKeys,
113-
function ($key) use ($targetColumn, $refTable, $refColumn) {
113+
function ($key) use ($targetColumn, $refTable) {
114114
return $key['COLUMN_NAME'] == $targetColumn
115115
&& $key['REF_TABLE_NAME'] == $refTable;
116116
}

setup/src/Magento/Setup/Console/Command/AdminUserCreateCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Setup\Console\Command;
88

99
use Magento\Framework\Setup\ConsoleLogger;
10+
use Magento\Framework\Validation\ValidationException;
1011
use Magento\Setup\Model\AdminAccount;
1112
use Magento\Setup\Model\InstallerFactory;
1213
use Magento\User\Model\UserValidationRules;
@@ -81,7 +82,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
8182
$question = new Question('<question>Admin password:</question> ', '');
8283
$question->setHidden(true);
8384

84-
$question->setValidator(function ($value) use ($output) {
85+
$question->setValidator(function ($value) {
8586
$user = new \Magento\Framework\DataObject();
8687
$user->setPassword($value);
8788

@@ -90,7 +91,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
9091

9192
$validator->isValid($user);
9293
foreach ($validator->getMessages() as $message) {
93-
throw new \Exception($message);
94+
throw new ValidationException(__($message));
9495
}
9596

9697
return $value;
@@ -143,7 +144,7 @@ private function addNotEmptyValidator(Question $question)
143144
{
144145
$question->setValidator(function ($value) {
145146
if (trim($value) == '') {
146-
throw new \Exception('The value cannot be empty');
147+
throw new ValidationException(__('The value cannot be empty'));
147148
}
148149

149150
return $value;

0 commit comments

Comments
 (0)