Skip to content

Commit 0e6be49

Browse files
committed
Fixed issue #26 with multiple wrappers.
1 parent 1653772 commit 0e6be49

15 files changed

+537
-114
lines changed

src/WSDL/XML/Styles/TypesElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TypesElement
3232
{
3333
private $_name;
3434
private $_elementAttributes = array();
35-
private $_complex;
35+
private $_complex = array();
3636

3737
public function setName($name)
3838
{
@@ -63,7 +63,7 @@ public function getComplex()
6363

6464
public function setComplex($complex)
6565
{
66-
$this->_complex = $complex;
66+
$this->_complex[] = $complex;
6767
return $this;
6868
}
6969
}

src/WSDL/XML/XMLGenerator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ private function _generateObject(TypesElement $parameter, $schemaElement)
207207
$sequenceElement->appendChild($elementPartElement);
208208
}
209209

210-
if ($parameter->getComplex()) {
211-
$this->_generateComplexType($parameter->getComplex(), $schemaElement);
210+
$complex = $parameter->getComplex();
211+
if ($complex) {
212+
foreach ($complex as $complexElement) {
213+
$this->_generateComplexType($complexElement, $schemaElement);
214+
}
212215
}
213216

214217
$complexTypeElement->appendChild($sequenceElement);

tests/Factory/ParameterFactory.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
<?php
22
/**
3-
* ParameterFactory
3+
* Copyright (C) 2013-2015
4+
* Piotr Olaszewski <[email protected]>
45
*
5-
* @author Piotr Olaszewski <[email protected]>
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
623
*/
724
namespace Factory;
825

926
use WSDL\Parser\MethodParser;
1027

28+
/**
29+
* ParameterFactory
30+
*
31+
* @author Piotr Olaszewski <[email protected]>
32+
*/
1133
class ParameterFactory
1234
{
1335
public static function createParameterForSimpleArray($methodName = '')
@@ -81,4 +103,13 @@ public static function createReturnObjectWithArrayOfWrapper($methodName = '')
81103
$doc = '/**@return object $listOfAgents @(wrapper[] $agents @className=\Mocks\MockUserWrapper) @int=$id*/';
82104
return new MethodParser($methodName, $doc);
83105
}
106+
107+
public static function createParameterWithMultipleWrappers($methodName = '')
108+
{
109+
$doc = '/**
110+
* @param wrapper $customer @className=\Mocks\WrapperClass\Customer
111+
* @param wrapper $purchase @className=\Mocks\WrapperClass\Purchase
112+
*/';
113+
return new MethodParser($methodName, $doc);
114+
}
84115
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2013-2015
4+
* Piotr Olaszewski <[email protected]>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
namespace Mocks;
25+
26+
class MockMultipleWrappers
27+
{
28+
/**
29+
* @WebMethod
30+
* @param string $name
31+
* @param wrapper $customer @className=\Mocks\WrapperClass\Customer
32+
* @param wrapper $purchase @className=\Mocks\WrapperClass\Purchase
33+
* @return wrapper $purchaseResult @className=\Mocks\WrapperClass\PurchaseResult
34+
*/
35+
public function multipleWrappers($name, $customer, $purchase)
36+
{
37+
return 1;
38+
}
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2013-2015
4+
* Piotr Olaszewski <[email protected]>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
namespace Mocks\WrapperClass;
25+
26+
class Customer
27+
{
28+
/**
29+
* @type string
30+
*/
31+
public $firstName;
32+
/**
33+
* @type string
34+
*/
35+
public $lastName;
36+
/**
37+
* @type string
38+
*/
39+
public $email;
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2013-2015
4+
* Piotr Olaszewski <[email protected]>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
namespace Mocks\WrapperClass;
25+
26+
class Purchase
27+
{
28+
/**
29+
* @type string
30+
*/
31+
public $bookingReference;
32+
/**
33+
* @type string
34+
*/
35+
public $orderNumber;
36+
/**
37+
* @type int
38+
*/
39+
public $quantity;
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright (C) 2013-2015
4+
* Piotr Olaszewski <[email protected]>
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
namespace Mocks\WrapperClass;
25+
26+
class PurchaseResult
27+
{
28+
/**
29+
* @type string
30+
*/
31+
public $couponsMissing = 0;
32+
/**
33+
* @type string
34+
*/
35+
public $couponsAvailable = 0;
36+
/**
37+
* @type string
38+
*/
39+
public $bookingsPerformed = 0;
40+
}

0 commit comments

Comments
 (0)