Skip to content

Commit c289d0c

Browse files
committed
MAGETWO-63881: Accept public PRs #8327, #8336, #8307
- covered additional numeric cases with the communication.xsd schema changes - added integration tests
1 parent b588edb commit c289d0c

File tree

6 files changed

+62
-4
lines changed

6 files changed

+62
-4
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,40 @@ 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 available. Given "V55\Customer\Api\CustomerRepositoryInterface::delete99"
30+
*/
31+
public function testGetTopicsNumeric()
32+
{
33+
$this->getConfigInstance(__DIR__ . '/_files/valid_communication_numeric.xml')->getTopics();
34+
}
35+
36+
/**
37+
* Get topic configuration by its name
38+
*
39+
* @expectedException \Magento\Framework\Exception\LocalizedException
40+
* @expectedExceptionMessage Invalid XML in file 0:
41+
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]+'.
42+
Line: 9
43+
44+
Element 'topic', attribute 'schema': '55\Customer\Api\CustomerRepositoryInterface::delete' is not a valid value of the atomic type 'schemaType'.
45+
Line: 9
46+
47+
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\\]+'.
48+
Line: 10
49+
50+
Element 'handler', attribute 'type': '55\Customer\Api\CustomerRepositoryInterface' is not a valid value of the atomic type 'serviceTypeType'.
51+
Line: 10
52+
*
53+
*/
54+
public function testGetTopicsNumericInvalid()
55+
{
56+
$this->getConfigInstance(__DIR__ . '/_files/invalid_communication_numeric.xml')->getTopics();
57+
}
58+
2559
/**
2660
* Get topic configuration by its name
2761
*/
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: 2 additions & 2 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>
@@ -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)