Skip to content

Commit ec041f6

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #14051: Issues 13769. Fix wrong info about sent email in order sender. (by @pawcioma) - #13789: Add quoting for base path in DI compile command (by @simpleadm) - #14043: Forward port of PR-13943: #12405: Impossible to creat… (by @hostep) Fixed GitHub Issues: - #13769: Order Email Sender (reported by @pawcioma) has been fixed in #14051 by @pawcioma in 2.3-develop branch Related commits: 1. 8d32059 - #12405: Magento 2.2.1 - Impossible to create a new storeview (reported by @hostep) has been fixed in #14043 by @hostep in 2.3-develop branch Related commits: 1. 7a2d715 - #12421: 'Requested store is not found' when trying to create a store view in the back end (reported by @Eminee) has been fixed in #14043 by @hostep in 2.3-develop branch Related commits: 1. 7a2d715
2 parents 33b92f6 + 08ae583 commit ec041f6

File tree

5 files changed

+89
-25
lines changed

5 files changed

+89
-25
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
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_Config" />
9+
<module name="Magento_Config">
10+
<sequence>
11+
<module name="Magento_Store"/>
12+
</sequence>
13+
</module>
1014
</config>

app/code/Magento/Sales/Model/Order/Email/Sender.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ protected function checkAndSend(Order $order)
8484
$sender->sendCopyTo();
8585
} catch (\Exception $e) {
8686
$this->logger->error($e->getMessage());
87+
88+
return false;
8789
}
8890

8991
return true;

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ protected function setUp()
5353
* @param int $configValue
5454
* @param bool|null $forceSyncMode
5555
* @param bool|null $emailSendingResult
56-
* @dataProvider sendDataProvider
56+
* @param $senderSendException
5757
* @return void
58+
* @dataProvider sendDataProvider
5859
*/
59-
public function testSend($configValue, $forceSyncMode, $emailSendingResult)
60+
public function testSend($configValue, $forceSyncMode, $emailSendingResult, $senderSendException)
6061
{
6162
$address = 'address_test';
6263
$configPath = 'sales_email/general/async_sending';
@@ -110,19 +111,23 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
110111

111112
$this->senderMock->expects($this->once())->method('send');
112113

113-
$this->senderMock->expects($this->once())->method('sendCopyTo');
114+
if ($senderSendException) {
115+
$this->checkSenderSendExceptionCase();
116+
} else {
117+
$this->senderMock->expects($this->once())->method('sendCopyTo');
114118

115-
$this->orderMock->expects($this->once())
116-
->method('setEmailSent')
117-
->with(true);
119+
$this->orderMock->expects($this->once())
120+
->method('setEmailSent')
121+
->with(true);
118122

119-
$this->orderResourceMock->expects($this->once())
120-
->method('saveAttribute')
121-
->with($this->orderMock, ['send_email', 'email_sent']);
123+
$this->orderResourceMock->expects($this->once())
124+
->method('saveAttribute')
125+
->with($this->orderMock, ['send_email', 'email_sent']);
122126

123-
$this->assertTrue(
124-
$this->sender->send($this->orderMock)
125-
);
127+
$this->assertTrue(
128+
$this->sender->send($this->orderMock)
129+
);
130+
}
126131
} else {
127132
$this->orderResourceMock->expects($this->once())
128133
->method('saveAttribute')
@@ -146,19 +151,42 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
146151
}
147152
}
148153

154+
/**
155+
* Methods check case when method "send" in "senderMock" throw exception.
156+
*
157+
* @return void
158+
*/
159+
protected function checkSenderSendExceptionCase()
160+
{
161+
$this->senderMock->expects($this->once())
162+
->method('send')
163+
->willThrowException(new \Exception('exception'));
164+
165+
$this->orderResourceMock->expects($this->once())
166+
->method('saveAttribute')
167+
->with($this->orderMock, 'send_email');
168+
169+
$this->assertFalse(
170+
$this->sender->send($this->orderMock)
171+
);
172+
}
173+
149174
/**
150175
* @return array
151176
*/
152177
public function sendDataProvider()
153178
{
154179
return [
155-
[0, 0, true],
156-
[0, 0, true],
157-
[0, 0, false],
158-
[0, 0, false],
159-
[0, 1, true],
160-
[0, 1, true],
161-
[1, null, null, null]
180+
[0, 0, true, false],
181+
[0, 0, true, false],
182+
[0, 0, true, true],
183+
[0, 0, false, false],
184+
[0, 0, false, false],
185+
[0, 0, false, true],
186+
[0, 1, true, false],
187+
[0, 1, true, false],
188+
[0, 1, true, false],
189+
[1, null, null, false]
162190
];
163191
}
164192

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private function getExcludedModulePaths(array $modulePaths)
239239
$vendorPathsRegExps[] = $vendorDir
240240
. '/(?:' . join('|', $vendorModules) . ')';
241241
}
242-
$basePathsRegExps[] = $basePath
242+
$basePathsRegExps[] = preg_quote($basePath, '#')
243243
. '/(?:' . join('|', $vendorPathsRegExps) . ')';
244244
}
245245

@@ -258,6 +258,10 @@ private function getExcludedModulePaths(array $modulePaths)
258258
*/
259259
private function getExcludedLibraryPaths(array $libraryPaths)
260260
{
261+
$libraryPaths = array_map(function ($libraryPath) {
262+
return preg_quote($libraryPath, '#');
263+
}, $libraryPaths);
264+
261265
$excludedLibraryPaths = [
262266
'#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?Test#',
263267
'#^(?:' . join('|', $libraryPaths) . ')/([\\w]+/)?tests#',
@@ -274,7 +278,7 @@ private function getExcludedLibraryPaths(array $libraryPaths)
274278
private function getExcludedSetupPaths($setupPath)
275279
{
276280
return [
277-
'#^(?:' . $setupPath . ')(/[\\w]+)*/Test#'
281+
'#^(?:' . preg_quote($setupPath, '#') . ')(/[\\w]+)*/Test#'
278282
];
279283
}
280284

setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Component\ComponentRegistrar;
99
use Magento\Setup\Console\Command\DiCompileCommand;
10+
use Magento\Setup\Module\Di\App\Task\OperationFactory;
1011
use Symfony\Component\Console\Tester\CommandTester;
1112

1213
/**
@@ -61,6 +62,10 @@ public function setUp()
6162
$this->managerMock = $this->createMock(\Magento\Setup\Module\Di\App\Task\Manager::class);
6263
$this->directoryListMock =
6364
$this->createMock(\Magento\Framework\App\Filesystem\DirectoryList::class);
65+
$this->directoryListMock->expects($this->any())->method('getPath')->willReturnMap([
66+
[\Magento\Framework\App\Filesystem\DirectoryList::SETUP, '/path (1)/to/setup/'],
67+
]);
68+
6469
$this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
6570
->disableOriginalConstructor()
6671
->getMock();
@@ -70,8 +75,8 @@ public function setUp()
7075
->getMock();
7176
$this->componentRegistrarMock = $this->createMock(\Magento\Framework\Component\ComponentRegistrar::class);
7277
$this->componentRegistrarMock->expects($this->any())->method('getPaths')->willReturnMap([
73-
[ComponentRegistrar::MODULE, ['/path/to/module/one', '/path/to/module/two']],
74-
[ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path/to/library/two']],
78+
[ComponentRegistrar::MODULE, ['/path/to/module/one', '/path (1)/to/module/two']],
79+
[ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path (1)/to/library/two']],
7580
]);
7681

7782
$this->command = new DiCompileCommand(
@@ -128,7 +133,28 @@ public function testExecute()
128133
->method('create')
129134
->with(\Symfony\Component\Console\Helper\ProgressBar::class)
130135
->willReturn($progressBar);
131-
$this->managerMock->expects($this->exactly(7))->method('addOperation');
136+
137+
$this->managerMock->expects($this->exactly(7))->method('addOperation')
138+
->withConsecutive(
139+
[OperationFactory::PROXY_GENERATOR, []],
140+
[OperationFactory::REPOSITORY_GENERATOR, $this->anything()],
141+
[OperationFactory::DATA_ATTRIBUTES_GENERATOR, []],
142+
[OperationFactory::APPLICATION_CODE_GENERATOR, $this->callback(function ($subject) {
143+
$this->assertEmpty(array_diff($subject['excludePatterns'], [
144+
"#^(?:/path \(1\)/to/setup/)(/[\w]+)*/Test#",
145+
"#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?Test#",
146+
"#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?tests#",
147+
"#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/Test#",
148+
"#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/tests#"
149+
]));
150+
return true;
151+
})],
152+
[OperationFactory::INTERCEPTION, $this->anything()],
153+
[OperationFactory::AREA_CONFIG_GENERATOR, $this->anything()],
154+
[OperationFactory::INTERCEPTION_CACHE, $this->anything()]
155+
)
156+
;
157+
132158
$this->managerMock->expects($this->once())->method('process');
133159
$tester = new CommandTester($this->command);
134160
$tester->execute([]);

0 commit comments

Comments
 (0)