Skip to content

Commit 158236c

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MC-18467
2 parents 12619b2 + b1bf05a commit 158236c

File tree

6 files changed

+121
-21
lines changed

6 files changed

+121
-21
lines changed

app/code/Magento/Customer/Model/Delegation/Storage.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
7-
86
declare(strict_types=1);
97

108
namespace Magento\Customer\Model\Delegation;
@@ -21,6 +19,7 @@
2119
use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
2220
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
2321
use Magento\Customer\Api\Data\AddressInterfaceFactory;
22+
use Magento\Framework\Api\CustomAttributesDataInterface;
2423
use Psr\Log\LoggerInterface;
2524

2625
/**
@@ -104,11 +103,13 @@ public function storeNewOperation(
104103
}
105104
}
106105
$this->session->setCustomerFormData($customerData);
107-
$this->session->setDelegatedNewCustomerData([
108-
'customer' => $customerData,
109-
'addresses' => $addressesData,
110-
'delegated_data' => $delegatedData
111-
]);
106+
$this->session->setDelegatedNewCustomerData(
107+
[
108+
'customer' => $customerData,
109+
'addresses' => $addressesData,
110+
'delegated_data' => $delegatedData,
111+
]
112+
);
112113
}
113114

114115
/**
@@ -138,18 +139,31 @@ public function consumeNewOperation()
138139
);
139140
$addressData['region'] = $region;
140141
}
141-
$addresses[] = $this->addressFactory->create(
142+
143+
$customAttributes = [];
144+
if (!empty($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) {
145+
$customAttributes = $addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES];
146+
unset($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]);
147+
}
148+
149+
$address = $this->addressFactory->create(
142150
['data' => $addressData]
143151
);
152+
153+
foreach ($customAttributes as $attributeCode => $attributeValue) {
154+
$address->setCustomAttribute($attributeCode, $attributeValue);
155+
}
156+
157+
$addresses[] = $address;
144158
}
145159
$customerData = $serialized['customer'];
146160
$customerData['addresses'] = $addresses;
147161

148-
return $this->newFactory->create([
149-
'customer' => $this->customerFactory->create(
150-
['data' => $customerData]
151-
),
152-
'additionalData' => $serialized['delegated_data']
153-
]);
162+
return $this->newFactory->create(
163+
[
164+
'customer' => $this->customerFactory->create(['data' => $customerData]),
165+
'additionalData' => $serialized['delegated_data'],
166+
]
167+
);
154168
}
155169
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="SearchByEmailInCustomerGridTest">
11+
<annotations>
12+
<features value="Customer"/>
13+
<stories value="Customer grid search"/>
14+
<title value="Admin customer grid email searching"/>
15+
<description value="Admin customer grid searching by email in keyword"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-18137"/>
18+
<useCaseId value="MC-17940"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
<createData entity="Simple_US_Customer" stepKey="createFirstCustomer"/>
23+
<createData entity="Simple_US_Customer" stepKey="createSecondCustomer"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createFirstCustomer" stepKey="deleteFirstCustomer"/>
28+
<deleteData createDataKey="createSecondCustomer" stepKey="deleteSecondCustomer"/>
29+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomersGridPage"/>
30+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearCustomerGridFilter"/>
31+
<actionGroup ref="logout" stepKey="logout"/>
32+
</after>
33+
<!--Step 1: Go to Customers > All Customers-->
34+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomersGridPage"/>
35+
<!--Step 2: On Customers grid page search customer by keyword-->
36+
<actionGroup ref="searchAdminDataGridByKeyword" stepKey="searchCustomer">
37+
<argument name="keyword" value="$$createSecondCustomer.email$$"/>
38+
</actionGroup>
39+
<!--Step 3: Check if customer is placed in a first row and clear grid filter-->
40+
<actionGroup ref="AdminAssertCustomerInCustomersGrid" stepKey="checkCustomerInGrid">
41+
<argument name="text" value="$$createSecondCustomer.email$$"/>
42+
<argument name="row" value="1"/>
43+
</actionGroup>
44+
</test>
45+
</tests>

dev/tests/integration/testsuite/Magento/Sales/Api/OrderCustomerDelegateInterfaceTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Sales\Api;
87

98
use Magento\Customer\Api\AccountManagementInterface;
@@ -17,6 +16,8 @@
1716
use PHPUnit\Framework\TestCase;
1817

1918
/**
19+
* Test for Magento\Sales\Api\OrderCustomerDelegateInterface class
20+
*
2021
* @magentoAppIsolation enabled
2122
*/
2223
class OrderCustomerDelegateInterfaceTest extends TestCase
@@ -47,7 +48,7 @@ class OrderCustomerDelegateInterfaceTest extends TestCase
4748
private $orderFactory;
4849

4950
/**
50-
* @inheritDoc
51+
* @inheritdoc
5152
*/
5253
protected function setUp()
5354
{
@@ -123,6 +124,7 @@ private function compareAddresses(
123124
/**
124125
* @magentoDbIsolation enabled
125126
* @magentoAppIsolation enabled
127+
* @magentoDataFixture Magento/Customer/_files/attribute_user_defined_address.php
126128
* @magentoDataFixture Magento/Sales/_files/order.php
127129
*/
128130
public function testDelegateNew()
@@ -131,7 +133,7 @@ public function testDelegateNew()
131133
/** @var Order $orderModel */
132134
$orderModel = $this->orderFactory->create();
133135
$orderModel->loadByIncrementId($orderAutoincrementId);
134-
$orderId = $orderModel->getId();
136+
$orderId = (int)$orderModel->getId();
135137
unset($orderModel);
136138

137139
$this->delegate->delegateNew($orderId);

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,12 @@ public function setTemplateOptions($templateOptions)
254254
*/
255255
public function getTransport()
256256
{
257-
$this->prepareMessage();
258-
$mailTransport = $this->mailTransportFactory->create(['message' => clone $this->message]);
259-
$this->reset();
257+
try {
258+
$this->prepareMessage();
259+
$mailTransport = $this->mailTransportFactory->create(['message' => clone $this->message]);
260+
} finally {
261+
$this->reset();
262+
}
260263

261264
return $mailTransport;
262265
}

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,34 @@ public function testGetTransport($templateType, $messageType, $bodyText, $templa
140140
$this->assertInstanceOf(\Magento\Framework\Mail\TransportInterface::class, $this->builder->getTransport());
141141
}
142142

143+
/**
144+
* Test get transport with exception
145+
*
146+
* @expectedException \LogicException
147+
* @expectedExceptionMessage Test error msg
148+
*/
149+
public function testGetTransportWithException()
150+
{
151+
$vars = ['reason' => 'Reason', 'customer' => 'Customer'];
152+
$options = ['area' => 'frontend', 'store' => 1];
153+
154+
$template = $this->createMock(\Magento\Framework\Mail\TemplateInterface::class);
155+
$template->method('setVars')->willReturnSelf();
156+
$template->method('setOptions')->willReturnSelf();
157+
$template->method('getSubject')->willReturn('Email Subject');
158+
$template->method('getType')->willReturn(TemplateTypesInterface::TYPE_TEXT);
159+
$template->method('processTemplate')->willReturn('Plain text');
160+
$this->templateFactoryMock->method('get')->willReturn($template);
161+
$this->messageMock->method('setSubject')->willReturnSelf();
162+
$this->messageMock->method('setMessageType')->willReturnSelf();
163+
$this->messageMock->method('setBody')->willReturnSelf();
164+
$this->messageFactoryMock->expects($this->once())->method('create');
165+
$this->mailTransportFactoryMock->method('create')->willThrowException(new \LogicException('Test error msg'));
166+
167+
$this->builder->setTemplateIdentifier('identifier')->setTemplateVars($vars)->setTemplateOptions($options);
168+
$this->assertInstanceOf(\Magento\Framework\Mail\TransportInterface::class, $this->builder->getTransport());
169+
}
170+
143171
/**
144172
* @return array
145173
*/

lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
*/
1616
class FulltextFilter implements FilterApplierInterface
1717
{
18+
/**
19+
* Patterns using for escaping special characters
20+
*/
21+
private $escapePatterns = [
22+
'/[@\.]/' => '\_',
23+
'/([+\-><\(\)~*]+)/' => ' ',
24+
];
25+
1826
/**
1927
* Returns list of columns from fulltext index (doesn't support more then one FTI per table)
2028
*
@@ -70,7 +78,7 @@ function ($column) use ($alias) {
7078
*/
7179
private function escapeAgainstValue(string $value): string
7280
{
73-
return preg_replace('/([+\-><\(\)~*@]+)/', ' ', $value);
81+
return preg_replace(array_keys($this->escapePatterns), array_values($this->escapePatterns), $value);
7482
}
7583

7684
/**

0 commit comments

Comments
 (0)