Skip to content

Commit

Permalink
MAGETWO-63881: Accept public PRs #8327, #8336, #8307
Browse files Browse the repository at this point in the history
- covered additional numeric cases with the communication.xsd schema changes
- added integration tests
  • Loading branch information
vrann committed Feb 1, 2017
1 parent b588edb commit c289d0c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ public function testGetTopics()
$this->assertEquals($expectedParsedTopics, $topics);
}

/**
* Get topic configuration by its name
*
* @expectedException \LogicException
* @expectedExceptionMessage Service method specified in the definition of topic "customerDeletedNumbers" is not available. Given "V55\Customer\Api\CustomerRepositoryInterface::delete99"
*/
public function testGetTopicsNumeric()
{
$this->getConfigInstance(__DIR__ . '/_files/valid_communication_numeric.xml')->getTopics();
}

/**
* Get topic configuration by its name
*
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Invalid XML in file 0:
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]+'.
Line: 9
Element 'topic', attribute 'schema': '55\Customer\Api\CustomerRepositoryInterface::delete' is not a valid value of the atomic type 'schemaType'.
Line: 9
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\\]+'.
Line: 10
Element 'handler', attribute 'type': '55\Customer\Api\CustomerRepositoryInterface' is not a valid value of the atomic type 'serviceTypeType'.
Line: 10
*
*/
public function testGetTopicsNumericInvalid()
{
$this->getConfigInstance(__DIR__ . '/_files/invalid_communication_numeric.xml')->getTopics();
}

/**
* Get topic configuration by its name
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="customerDeletedNumbers" schema="55\Customer\Api\CustomerRepositoryInterface::99delete">
<handler name="customHandler" type="55\Customer\Api\CustomerRepositoryInterface" method="99deleteById"/>
</topic>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="customerDeletedNumbers" schema="V55\Customer\Api\CustomerRepositoryInterface::delete99">
<handler name="customHandler" type="V55\Customer\Api\CustomerRepositoryInterface" method="deleteById99"/>
</topic>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConfigParser
*/
public function parseServiceMethod($serviceMethod)
{
$pattern = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';
$pattern = '/^([a-zA-Z]+[a-zA-Z0-9\\\\]+)::([a-zA-Z0-9]+)$/';
preg_match($pattern, $serviceMethod, $matches);
if (!isset($matches[1]) || !isset($matches[2])) {
throw new LocalizedException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
{
/**
* @deprecated
* @see ConfigParser::SERVICE_METHOD_NAME_PATTERN
* @see ConfigParser::parseServiceMethod
*/
const SERVICE_METHOD_NAME_PATTERN = '/^([a-zA-Z\\\\]+)::([a-zA-Z]+)$/';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z\\]+::[a-zA-Z]+" />
<xs:pattern value="[a-zA-Z]+[a-zA-Z0-9\\]+::[a-zA-Z0-9]+" />
<xs:minLength value="5" />
</xs:restriction>
</xs:simpleType>
Expand All @@ -76,7 +76,7 @@
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z]+" />
<xs:pattern value="[a-zA-Z0-9]+" />
<xs:minLength value="2" />
</xs:restriction>
</xs:simpleType>
Expand Down

0 comments on commit c289d0c

Please sign in to comment.