Completed
Push — master ( 1fcf02...437edc )
by Piotr
03:44
created

XMLEncodedUseTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 39.53 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 4
dl 17
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A useType() 0 4 1
A shouldGenerateSoapBody() 0 11 1
A shouldGenerateHeader() 17 17 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\XML\XMLUse;
25
26
use WSDL\Annotation\SoapBinding;
27
use WSDL\Builder\Parameter;
28
use WSDL\Parser\Node;
29
30
/**
31
 * XMLEncodedUseTest
32
 *
33
 * @author Piotr Olaszewski <[email protected]>
34
 */
35
class XMLEncodedUseTest extends XMLBaseUseTest
36
{
37
    public function useType()
38
    {
39
        return SoapBinding::ENCODED;
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function shouldGenerateSoapBody()
46
    {
47
        //when
48
        $soapBody = $this->XMLUse->generateSoapBody($this->DOMDocument, $this->targetNamespace, $this->soapVersion);
49
50
        //then
51
        $this->assertEquals('soap:body', $soapBody->tagName);
52
        $this->assertEquals('encoded', $soapBody->getAttribute('use'));
53
        $this->assertEquals($this->targetNamespace, $soapBody->getAttribute('namespace'));
54
        $this->assertEquals('http://schemas.xmlsoap.org/soap/encoding/', $soapBody->getAttribute('encodingStyle'));
55
    }
56
57
    /**
58
     * @test
59
     */
60 View Code Duplication
    public function shouldGenerateHeader()
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...
61
    {
62
        //given
63
        $header = new Parameter(new Node('int', '$key', false), true);
64
65
        //when
66
        $soapHeaderIfNeeded = $this
67
            ->XMLUse
68
            ->generateSoapHeaderIfNeeded($this->DOMDocument, $this->targetNamespace, $this->soapHeaderMessage, $header, $this->soapVersion);
69
70
        //then
71
        $this->assertEquals('soap:header', $soapHeaderIfNeeded->tagName);
72
        $this->assertEquals('encoded', $soapHeaderIfNeeded->getAttribute('use'));
73
        $this->assertEquals($this->targetNamespace, $soapHeaderIfNeeded->getAttribute('namespace'));
74
        $this->assertEquals('key', $soapHeaderIfNeeded->getAttribute('part'));
75
        $this->assertEquals($this->soapHeaderMessage, $soapHeaderIfNeeded->getAttribute('message'));
76
    }
77
}
78