EndpointTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 14.49 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 10
loc 69
rs 10
c 1
b 1
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testapiKey() 0 5 1
A testWsdl() 0 5 1
A testOptions() 0 7 1
A testClient() 0 8 1
A testClientInvalidWSDL() 10 10 1
A test__construct() 0 6 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
/*
4
 * For the full copyright and license information, please view the LICENSE file
5
 * that was distributed with this source code.
6
 */
7
8
declare (strict_types = 1);
9
10
namespace Component\Remote\BurzeDzisNet;
11
12
use PHPUnit_Framework_TestCase;
13
14
/**
15
 * {@see Endpoint} test.
16
 *
17
 * @author Krzysztof Piasecki <[email protected]>
18
 */
19
class EndpointTest extends PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @covers Component\Remote\BurzeDzisNet\apiKey::apikey
23
     */
24
    public function testapiKey()
25
    {
26
        $endpoint = new Endpoint('MyApiKey');
27
        $this->assertSame('MyApiKey', $endpoint->apiKey());
28
    }
29
30
    /**
31
     * @covers Component\Remote\BurzeDzisNet\Endpoint::wsdl
32
     */
33
    public function testWsdl()
34
    {
35
        $endpoint = new Endpoint('MyApiKey');
36
        $this->assertSame('https://burze.dzis.net/soap.php?WSDL', $endpoint->wsdl());
37
    }
38
39
    /**
40
     * @covers Component\Remote\BurzeDzisNet\Endpoint::options
41
     */
42
    public function testOptions()
43
    {
44
        $endpoint = new Endpoint('MyApiKey');
45
        $this->assertEquals([], $endpoint->options());
46
        $endpoint2 = new Endpoint('MyApiKey', ['option' => true]);
47
        $this->assertEquals(['option' => true], $endpoint2->options());
48
    }
49
50
    /**
51
     * @covers Component\Remote\BurzeDzisNet\Endpoint::client
52
     */
53
    public function testClient()
54
    {
55
        $endpoint = new Endpoint('MyApiKey');
56
        $client = $endpoint->client();
57
        $client2 = $endpoint->client();
58
        $this->assertInstanceOf('SoapClient', $client);
59
        $this->assertNotSame($client, $client2);
60
    }
61
62
    /**
63
     * @covers Component\Remote\BurzeDzisNet\Endpoint::client
64
     *
65
     * @expectedException \SoapFault
66
     */
67 View Code Duplication
    public function testClientInvalidWSDL()
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...
68
    {
69
        $endpoint = $this->getMockBuilder("Component\Remote\BurzeDzisNet\Endpoint")
70
            ->disableOriginalConstructor()
71
            ->setMethods(['wsdl', 'options'])
72
            ->getMock();
73
        $endpoint->method('wsdl')->willReturn(\sprintf('%s%sInvalidExampleWSDL.xml', __DIR__, \DIRECTORY_SEPARATOR));
74
        $endpoint->method('options')->willReturn([]);
75
        $endpoint->client();
76
    }
77
78
    /**
79
     * @covers Component\Remote\BurzeDzisNet\Endpoint::__construct
80
     */
81
    public function test__construct()
82
    {
83
        $endpoint = new Endpoint('MyApiKey');
84
        $this->assertSame('https://burze.dzis.net/soap.php?WSDL', $endpoint->wsdl());
85
        $this->assertSame('MyApiKey', $endpoint->apiKey());
86
    }
87
}
88