GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

XMLGeneratorTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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
use Ouzo\Utilities\Path;
25
use WSDL\Parser\ClassParser;
26
use WSDL\XML\Styles\DocumentLiteralWrapped;
27
use WSDL\XML\Styles\RpcEncoded;
28
use WSDL\XML\Styles\RpcLiteral;
29
use WSDL\XML\XMLGenerator;
30
31
/**
32
 * XMLGeneratorTest
33
 *
34
 * @author Piotr Olaszewski <[email protected]>
35
 */
36
class XMLGeneratorTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
37
{
38
    /**
39
     * @var XMLGenerator
40
     */
41
    private $_XMLGenerator;
42
    private $_XML;
43
    private $_class = '\Mocks\MockClass';
44
    private $_namespace = 'http://example.com/';
45
    private $_location = 'http://localhost/wsdl-creator/ExampleSoapServer.php';
46
47
    public function setUp()
48
    {
49
        parent::setUp();
50
        $classParser = new ClassParser('\Mocks\MockClass');
51
        $classParser->parse();
52
53
        XMLGenerator::$alreadyGeneratedComplexTypes = array();
54
        $XMLGenerator = new XMLGenerator($this->_class, $this->_namespace, $this->_location);
55
        $XMLGenerator->setWSDLMethods($classParser->getMethods())->setBindingStyle(new RpcLiteral())->generate();
56
        $this->_XMLGenerator = $XMLGenerator;
57
        $this->_XML = $XMLGenerator->getGeneratedXML();
58
    }
59
60
    /**
61
     * @test
62
     */
63
    public function shouldGenerateWsdl()
64
    {
65
        //then
66
        $file = Path::join(__DIR__, 'xml_file_asserts', 'correct_wsdl.wsdl');
67
        $this->assertXmlStringEqualsXmlFile($file, $this->_XML);
68
    }
69
70
    /**
71
     * @test
72
     */
73
    public function shouldRenderXML()
74
    {
75
        //when
76
        $this->expectOutputRegex('/definitions.*message.*portType.*binding.*service/is');
77
        $this->_XMLGenerator->render();
78
    }
79
80
    /**
81
     * @test
82
     */
83
    public function shouldSanitizeClass()
84
    {
85
        //given
86
        $xml = new XMLGenerator('\Mocks\Test\MockClassMultipleNamespace', '', '');
87
88
        //when
89
        $sanitized = $xml->sanitizeClassName('http://foo.bar/', '\Mocks\Test\MockClassMultipleNamespace');
90
91
        //then
92
        $this->assertEquals('http://foo.bar/mocks/test/mockclassmultiplenamespace', $sanitized);
93
    }
94
95
    /**
96
     * @test
97
     */
98 View Code Duplication
    public function shouldCreateWSDLWithCorrectNamespace()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
    {
100
        //given
101
        $classParser = new ClassParser('\Mocks\Test\MockClassMultipleNamespace');
102
        $classParser->parse();
103
        XMLGenerator::$alreadyGeneratedComplexTypes = array();
104
        $xml = new XMLGenerator('\Mocks\Test\MockClassMultipleNamespace', $this->_namespace, $this->_location);
105
        $xml->setWSDLMethods($classParser->getMethods())->setBindingStyle(new RpcLiteral())->generate();
106
107
        //when
108
        $wsdl = $xml->getGeneratedXML();
109
110
        //then
111
        $file = Path::join(__DIR__, 'xml_file_asserts', 'correct_multi_class_wsdl.wsdl');
112
        $this->assertXmlStringEqualsXmlFile($file, $wsdl);
113
    }
114
115
    /**
116
     * @test
117
     */
118
    public function shouldCorrectParseWrapperElement()
119
    {
120
        //given
121
        XMLGenerator::$alreadyGeneratedComplexTypes = array();
122
        $classParser = new ClassParser('\Mocks\MockClass');
123
        $classParser->parse();
124
        $xml = new XMLGenerator('\Mocks\MockClass', $this->_namespace, $this->_location);
125
        $xml->setWSDLMethods($classParser->getMethods())->setBindingStyle(new RpcLiteral())->generate();
126
127
        //when
128
        $wsdl = $xml->getGeneratedXML();
129
130
        //then
131
        $this->assertRegExp('/MocksMockUserWrapper.*name="id" type="xsd:int".*name="name" type="xsd:string".*name="age" type="xsd:int"/is', $wsdl);
132
    }
133
134
    /**
135
     * @test
136
     */
137 View Code Duplication
    public function shouldAddEncodingUriForRpcEncoded()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        //given
140
        XMLGenerator::$alreadyGeneratedComplexTypes = array();
141
        $classParser = new ClassParser('\Mocks\MockClass');
142
        $classParser->parse();
143
        $xml = new XMLGenerator('\Mocks\MockClass', $this->_namespace, $this->_location);
144
        $xml->setWSDLMethods($classParser->getMethods())->setBindingStyle(new RpcEncoded())->generate();
145
146
        //when
147
        $wsdl = $xml->getGeneratedXML();
148
149
        //then
150
        $file = Path::join(__DIR__, 'xml_file_asserts', 'correct_rpc_encoded_wsdl.wsdl');
151
        $this->assertXmlStringEqualsXmlFile($file, $wsdl);
152
    }
153
154
    /**
155
     * @test
156
     */
157 View Code Duplication
    public function shouldCorrectCreateWsdlWithMultipleWrappersForDocumentLiteralWrapped()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
158
    {
159
        //given
160
        XMLGenerator::$alreadyGeneratedComplexTypes = array();
161
        $classParser = new ClassParser('\Mocks\MockMultipleWrappers');
162
        $classParser->parse();
163
        $xml = new XMLGenerator('\Mocks\MockMultipleWrappers', $this->_namespace, $this->_location);
164
        $xml->setWSDLMethods($classParser->getMethods())->setBindingStyle(new DocumentLiteralWrapped())->generate();
165
166
        //when
167
        $wsdl = $xml->getGeneratedXML();
168
169
        //then
170
        $file = Path::join(__DIR__, 'xml_file_asserts', 'multiple_wrappers.wsdl');
171
        $this->assertXmlStringEqualsXmlFile($file, $wsdl);
172
    }
173
}
174