From 03976e44a7cde0349a57ff55f2ab1edd0bfd2a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20W=C3=BChr?= Date: Mon, 5 May 2014 15:19:58 +0200 Subject: [PATCH 1/5] Fix double registration of a complex type Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType::addComplexType() stores already added classes under the methods argument `$type`. Therefore a class with preceding backslash is treated like another complextype than the same class without given backslash. As a result the xsd:ComplexType definition is found twice (with exactly the same name) in the generated wsdl. --- src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php | 12 ++++++------ test/Wsdl/DefaultComplexTypeTest.php | 10 ++++++++++ test/WsdlTest.php | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index ce45fbd9..ab1bd665 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -32,19 +32,19 @@ public function addComplexType($type) )); } - if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + $class = new ReflectionClass($type); + $phpType = $class->getName(); + + if (($soapType = $this->scanRegisteredTypes($phpType)) !== null) { return $soapType; } $dom = $this->getContext()->toDomDocument(); - $class = new ReflectionClass($type); - - $soapTypeName = $this->getContext()->translateType($type); + $soapTypeName = $this->getContext()->translateType($phpType); $soapType = Wsdl::TYPES_NS . ':' . $soapTypeName; // Register type here to avoid recursion - $this->getContext()->addType($type, $soapType); - + $this->getContext()->addType($phpType, $soapType); $defaultProperties = $class->getDefaultProperties(); diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index 848dc205..a5febc2f 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -49,4 +49,14 @@ public function testOnlyPublicPropertiesAreDiscoveredByStrategy() $this->testDocumentNodes(); } + + public function testDoubleClassesAreDiscoveredByStrategy() { + $this->strategy->addComplexType('ZendTest\Soap\TestAsset\WsdlTestClass'); + $this->strategy->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); + + $nodes = $this->xpath->query('//xsd:complexType[@name="WsdlTestClass"]'); + $this->assertEquals(1, $nodes->length); + + $this->testDocumentNodes(); + } } diff --git a/test/WsdlTest.php b/test/WsdlTest.php index ed4508d5..432b65d8 100644 --- a/test/WsdlTest.php +++ b/test/WsdlTest.php @@ -668,7 +668,7 @@ public function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); $this->assertEquals( array( - '\ZendTest\Soap\TestAsset\WsdlTestClass' => 'tns:WsdlTestClass' + 'ZendTest\Soap\TestAsset\WsdlTestClass' => 'tns:WsdlTestClass' ), $this->wsdl->getTypes() ); @@ -676,7 +676,7 @@ public function testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition() $this->wsdl->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); $this->assertEquals( array( - '\ZendTest\Soap\TestAsset\WsdlTestClass' => 'tns:WsdlTestClass' + 'ZendTest\Soap\TestAsset\WsdlTestClass' => 'tns:WsdlTestClass' ), $this->wsdl->getTypes() ); From 0907ac1cf174c7415b1ddd53403617d4d267d352 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 15 May 2014 03:18:22 +0200 Subject: [PATCH 2/5] zendframework/zf2#6223 - cs (alignment) --- src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php index ab1bd665..5ad645de 100644 --- a/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php +++ b/src/Wsdl/ComplexTypeStrategy/DefaultComplexType.php @@ -32,7 +32,7 @@ public function addComplexType($type) )); } - $class = new ReflectionClass($type); + $class = new ReflectionClass($type); $phpType = $class->getName(); if (($soapType = $this->scanRegisteredTypes($phpType)) !== null) { From dab619a15f5ad82373f883215d39ee636637b734 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 15 May 2014 03:19:34 +0200 Subject: [PATCH 3/5] zendframework/zf2#6223 - cs (braces on own line) --- test/Wsdl/DefaultComplexTypeTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index a5febc2f..cf22d622 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -50,7 +50,8 @@ public function testOnlyPublicPropertiesAreDiscoveredByStrategy() $this->testDocumentNodes(); } - public function testDoubleClassesAreDiscoveredByStrategy() { + public function testDoubleClassesAreDiscoveredByStrategy() + { $this->strategy->addComplexType('ZendTest\Soap\TestAsset\WsdlTestClass'); $this->strategy->addComplexType('\ZendTest\Soap\TestAsset\WsdlTestClass'); From 70a00fc1e6356230517d8ff4a6b01ed30f11fb32 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 15 May 2014 03:20:15 +0200 Subject: [PATCH 4/5] zendframework/zf2#6223 - coverage annotation --- test/Wsdl/DefaultComplexTypeTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index cf22d622..08a36fd7 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -17,8 +17,7 @@ require_once __DIR__ . '/../TestAsset/commontypes.php'; /** - * @group Zend_Soap - * @group Zend_Soap_Wsdl + * @covers \Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType */ class DefaultComplexTypeTest extends WsdlTestHelper { From 21d941823a4466bb99e26bad7cbacb6de44f7ddb Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 15 May 2014 03:20:29 +0200 Subject: [PATCH 5/5] zendframework/zf2#6223 - removing unused imports --- test/Wsdl/DefaultComplexTypeTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Wsdl/DefaultComplexTypeTest.php b/test/Wsdl/DefaultComplexTypeTest.php index 08a36fd7..7c04dd2f 100644 --- a/test/Wsdl/DefaultComplexTypeTest.php +++ b/test/Wsdl/DefaultComplexTypeTest.php @@ -10,7 +10,6 @@ namespace ZendTest\Soap\Wsdl; use Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType; -use Zend\Soap\Wsdl; use ZendTest\Soap\TestAsset\PublicPrivateProtected; use ZendTest\Soap\WsdlTestHelper;