Skip to content

Commit e67a97d

Browse files
committed
Merge branch 'MAGETWO-63881' into develop-prs
2 parents f876aba + 4b586aa commit e67a97d

File tree

9 files changed

+128
-7
lines changed

9 files changed

+128
-7
lines changed

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public function getProcessedTemplate(array $variables = [])
352352
$result = $processor->filter($this->getTemplateText());
353353
} catch (\Exception $e) {
354354
$this->cancelDesignConfig();
355-
throw new \LogicException(__($e->getMessage()), $e);
355+
throw new \LogicException(__($e->getMessage()), $e->getCode(), $e);
356356
}
357357
if ($isDesignApplied) {
358358
$this->cancelDesignConfig();

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,67 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
241241
$this->assertEquals($expectedResult, $model->getProcessedTemplate($variables));
242242
}
243243

244+
/**
245+
* @expectedException \LogicException
246+
*/
247+
public function testGetProcessedTemplateException() {
248+
$filterTemplate = $this->getMockBuilder(\Magento\Email\Model\Template\Filter::class)
249+
->setMethods([
250+
'setUseSessionInUrl',
251+
'setPlainTemplateMode',
252+
'setIsChildTemplate',
253+
'setDesignParams',
254+
'setVariables',
255+
'setStoreId',
256+
'filter',
257+
'getStoreId',
258+
'getInlineCssFiles',
259+
])
260+
->disableOriginalConstructor()
261+
->getMock();
262+
$filterTemplate->expects($this->once())
263+
->method('setUseSessionInUrl')
264+
->will($this->returnSelf());
265+
$filterTemplate->expects($this->once())
266+
->method('setPlainTemplateMode')
267+
->will($this->returnSelf());
268+
$filterTemplate->expects($this->once())
269+
->method('setIsChildTemplate')
270+
->will($this->returnSelf());
271+
$filterTemplate->expects($this->once())
272+
->method('setDesignParams')
273+
->will($this->returnSelf());
274+
$filterTemplate->expects($this->any())
275+
->method('setStoreId')
276+
->will($this->returnSelf());
277+
$filterTemplate->expects($this->any())
278+
->method('getStoreId')
279+
->will($this->returnValue(1));
280+
281+
$model = $this->getModelMock([
282+
'getDesignParams',
283+
'applyDesignConfig',
284+
'getTemplateText',
285+
'isPlain',
286+
]);
287+
288+
$designParams = [
289+
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
290+
'theme' => 'themeId',
291+
'locale' => 'localeId',
292+
];
293+
$model->expects($this->any())
294+
->method('getDesignParams')
295+
->will($this->returnValue($designParams));
296+
$model->setTemplateFilter($filterTemplate);
297+
$model->setTemplateType(\Magento\Framework\App\TemplateTypesInterface::TYPE_TEXT);
298+
299+
$filterTemplate->expects($this->once())
300+
->method('filter')
301+
->will($this->throwException(new \Exception));
302+
$model->getProcessedTemplate([]);
303+
}
304+
244305
/**
245306
* @return array
246307
*/

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
187187
<item name="dataType" xsi:type="string">date</item>
188188
<item name="label" xsi:type="string" translate="true">Purchase Date</item>
189-
<item name="dateFormat" xsi:type="string">MMM dd, YYYY, H:MM:SS A</item>
189+
<item name="dateFormat" xsi:type="string">MMM dd, YYYY, H:mm:ss A</item>
190190
</item>
191191
</argument>
192192
</column>

dev/tests/integration/testsuite/Magento/Framework/Communication/ConfigTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,42 @@ public function testGetTopics()
2222
$this->assertEquals($expectedParsedTopics, $topics);
2323
}
2424

25+
/**
26+
* Get topic configuration by its name
27+
*
28+
* @expectedException \LogicException
29+
* @expectedExceptionMessage Service method specified in the definition of topic "customerDeletedNumbers" is not av
30+
*/
31+
public function testGetTopicsNumeric()
32+
{
33+
$this->getConfigInstance(__DIR__ . '/_files/valid_communication_numeric.xml')->getTopics();
34+
}
35+
36+
// @codingStandardsIgnoreStart
37+
/**
38+
* Get topic configuration by its name
39+
*
40+
* @expectedException \Magento\Framework\Exception\LocalizedException
41+
* @expectedExceptionMessage Invalid XML in file 0:
42+
Element 'topic', attribute 'schema': [facet 'pattern'] The value '55\Customer\Api\CustomerRepositoryInterface::delete' is not accepted by the pattern '[a-zA-Z]+[a-zA-Z0-9\\]+::[a-zA-Z0-9]+'.
43+
Line: 9
44+
45+
Element 'topic', attribute 'schema': '55\Customer\Api\CustomerRepositoryInterface::delete' is not a valid value of the atomic type 'schemaType'.
46+
Line: 9
47+
48+
Element 'handler', attribute 'type': [facet 'pattern'] The value '55\Customer\Api\CustomerRepositoryInterface' is not accepted by the pattern '[a-zA-Z]+[a-zA-Z0-9\\]+'.
49+
Line: 10
50+
51+
Element 'handler', attribute 'type': '55\Customer\Api\CustomerRepositoryInterface' is not a valid value of the atomic type 'serviceTypeType'.
52+
Line: 10
53+
*
54+
*/
55+
// @codingStandardsIgnoreEnd
56+
public function testGetTopicsNumericInvalid()
57+
{
58+
$this->getConfigInstance(__DIR__ . '/_files/invalid_communication_numeric.xml')->getTopics();
59+
}
60+
2561
/**
2662
* Get topic configuration by its name
2763
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
9+
<topic name="customerDeletedNumbers" schema="55\Customer\Api\CustomerRepositoryInterface::99delete">
10+
<handler name="customHandler" type="55\Customer\Api\CustomerRepositoryInterface" method="99deleteById"/>
11+
</topic>
12+
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
9+
<topic name="customerDeletedNumbers" schema="V55\Customer\Api\CustomerRepositoryInterface::delete99">
10+
<handler name="customHandler" type="V55\Customer\Api\CustomerRepositoryInterface" method="deleteById99"/>
11+
</topic>
12+
</config>

lib/internal/Magento/Framework/Communication/Config/ConfigParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConfigParser
2525
*/
2626
public function parseServiceMethod($serviceMethod)
2727
{
28-
$pattern = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';
28+
$pattern = '/^([a-zA-Z]+[a-zA-Z0-9\\\\]+)::([a-zA-Z0-9]+)$/';
2929
preg_match($pattern, $serviceMethod, $matches);
3030
if (!isset($matches[1]) || !isset($matches[2])) {
3131
throw new LocalizedException(

lib/internal/Magento/Framework/Communication/Config/Reader/XmlReader/Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
1919
{
2020
/**
2121
* @deprecated
22-
* @see ConfigParser::SERVICE_METHOD_NAME_PATTERN
22+
* @see ConfigParser::parseServiceMethod
2323
*/
2424
const SERVICE_METHOD_NAME_PATTERN = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';
2525

lib/internal/Magento/Framework/Communication/etc/communication.xsd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</xs:documentation>
5555
</xs:annotation>
5656
<xs:restriction base="xs:string">
57-
<xs:pattern value="[a-zA-Z\\]+::[a-zA-Z]+" />
57+
<xs:pattern value="[a-zA-Z]+[a-zA-Z0-9\\]+::[a-zA-Z0-9]+" />
5858
<xs:minLength value="5" />
5959
</xs:restriction>
6060
</xs:simpleType>
@@ -65,7 +65,7 @@
6565
</xs:documentation>
6666
</xs:annotation>
6767
<xs:restriction base="xs:string">
68-
<xs:pattern value="[a-zA-Z\\]+" />
68+
<xs:pattern value="[a-zA-Z]+[a-zA-Z0-9\\]+" />
6969
<xs:minLength value="4" />
7070
</xs:restriction>
7171
</xs:simpleType>
@@ -76,7 +76,7 @@
7676
</xs:documentation>
7777
</xs:annotation>
7878
<xs:restriction base="xs:string">
79-
<xs:pattern value="[a-zA-Z]+" />
79+
<xs:pattern value="[a-zA-Z0-9]+" />
8080
<xs:minLength value="2" />
8181
</xs:restriction>
8282
</xs:simpleType>

0 commit comments

Comments
 (0)