1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (C) 2013-2016 |
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 Tests\WSDL\Builder; |
25
|
|
|
|
26
|
|
|
use Ouzo\Tests\Assert; |
27
|
|
|
use PHPUnit_Framework_TestCase; |
28
|
|
|
use WSDL\Annotation\BindingType; |
29
|
|
|
use WSDL\Annotation\SoapBinding; |
30
|
|
|
use WSDL\Builder\AnnotationWSDLBuilder; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* AnnotationWSDLBuilderTest |
34
|
|
|
* |
35
|
|
|
* @author Piotr Olaszewski <[email protected]> |
36
|
|
|
*/ |
37
|
|
|
class AnnotationWSDLBuilderTest extends PHPUnit_Framework_TestCase |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @test |
41
|
|
|
*/ |
42
|
|
|
public function shouldCreateBuilderForWebServiceAnnotation() |
43
|
|
|
{ |
44
|
|
|
//given |
45
|
|
|
$annotationWSDLBuilder = new AnnotationWSDLBuilder('\Fixtures\WebServiceAllAnnotations'); |
46
|
|
|
|
47
|
|
|
//when |
48
|
|
|
$annotationWSDLBuilder->build(); |
49
|
|
|
|
50
|
|
|
//then |
51
|
|
|
$WSDLBuilder = $annotationWSDLBuilder->getBuilder(); |
52
|
|
|
$this->assertEquals('WebServiceAnnotations', $WSDLBuilder->getName()); |
53
|
|
|
$this->assertEquals('http://foo.bar/webserviceannotations', $WSDLBuilder->getTargetNamespace()); |
54
|
|
|
$this->assertEquals('http://foo.bar/webserviceannotations/types', $WSDLBuilder->getNs()); |
55
|
|
|
$this->assertEquals('http://localhost/wsdl-creator/service.php', $WSDLBuilder->getLocation()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @test |
60
|
|
|
*/ |
61
|
|
|
public function shouldCreateBuilderForBindingTypeAnnotation() |
62
|
|
|
{ |
63
|
|
|
//given |
64
|
|
|
$annotationWSDLBuilder = new AnnotationWSDLBuilder('\Fixtures\WebServiceAllAnnotations'); |
65
|
|
|
|
66
|
|
|
//when |
67
|
|
|
$annotationWSDLBuilder->build(); |
68
|
|
|
|
69
|
|
|
//then |
70
|
|
|
$WSDLBuilder = $annotationWSDLBuilder->getBuilder(); |
71
|
|
|
$this->assertEquals(BindingType::SOAP_12, $WSDLBuilder->getSoapVersion()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @test |
76
|
|
|
*/ |
77
|
|
|
public function shouldCreateBuilderForSoapBindingAnnotation() |
78
|
|
|
{ |
79
|
|
|
//given |
80
|
|
|
$annotationWSDLBuilder = new AnnotationWSDLBuilder('\Fixtures\WebServiceAllAnnotations'); |
81
|
|
|
|
82
|
|
|
//when |
83
|
|
|
$annotationWSDLBuilder->build(); |
84
|
|
|
|
85
|
|
|
//then |
86
|
|
|
$WSDLBuilder = $annotationWSDLBuilder->getBuilder(); |
87
|
|
|
$this->assertEquals(SoapBinding::DOCUMENT, $WSDLBuilder->getStyle()); |
88
|
|
|
$this->assertEquals(SoapBinding::ENCODED, $WSDLBuilder->getUse()); |
89
|
|
|
$this->assertEquals(SoapBinding::WRAPPED, $WSDLBuilder->getParameterStyle()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @test |
94
|
|
|
*/ |
95
|
|
|
public function shouldCreateBuilderWithClassNameWhenNameIsNotPass() |
96
|
|
|
{ |
97
|
|
|
//given |
98
|
|
|
$annotationWSDLBuilder = new AnnotationWSDLBuilder('\Fixtures\WebServiceClassAnnotations'); |
99
|
|
|
|
100
|
|
|
//when |
101
|
|
|
$annotationWSDLBuilder->build(); |
102
|
|
|
|
103
|
|
|
//then |
104
|
|
|
$WSDLBuilder = $annotationWSDLBuilder->getBuilder(); |
105
|
|
|
$this->assertEquals('WebServiceClassAnnotations', $WSDLBuilder->getName()); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @test |
110
|
|
|
*/ |
111
|
|
|
public function shouldCreateBuilderWithMethods() |
112
|
|
|
{ |
113
|
|
|
//given |
114
|
|
|
$annotationWSDLBuilder = new AnnotationWSDLBuilder('\Fixtures\WebServiceAllAnnotations'); |
115
|
|
|
|
116
|
|
|
//when |
117
|
|
|
$annotationWSDLBuilder->build(); |
118
|
|
|
|
119
|
|
|
//then |
120
|
|
|
$WSDLBuilder = $annotationWSDLBuilder->getBuilder(); |
121
|
|
|
Assert::thatArray($WSDLBuilder->getMethods()) |
122
|
|
|
->extracting('name') |
123
|
|
|
->containsOnly('uppercaseUserName', 'appendPrefixToNumbers', 'getUserContext'); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|