Completed
Push — master ( 580c08...50e7bb )
by Tobias
26:18 queued 54s
created

HttpClientConfiguratorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 90.32 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 56
loc 62
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testAppendPlugin() 16 16 1
A testAppendPluginMultiple() 12 12 1
A testPrependPlugin() 16 16 1
A testPrependPluginMultiple() 12 12 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
namespace Happyr\ApiClient\Test;
4
5
use Happyr\ApiClient\HttpClientConfigurator;
6
use Http\Client\Common\Plugin\HeaderAppendPlugin;
7
use Nyholm\NSA;
8
9
final class HttpClientConfiguratorTest extends \PHPUnit_Framework_TestCase
10
{
11 View Code Duplication
    public function testAppendPlugin()
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...
12
    {
13
        $hcc = new HttpClientConfigurator();
14
        $plugin0 = new HeaderAppendPlugin(['plugin0']);
15
16
        $hcc->appendPlugin($plugin0);
17
        $plugins = NSA::getProperty($hcc, 'appendPlugins');
18
        $this->assertCount(1, $plugins);
19
        $this->assertEquals($plugin0, $plugins[0]);
20
21
        $plugin1 = new HeaderAppendPlugin(['plugin1']);
22
        $hcc->appendPlugin($plugin1);
23
        $plugins = NSA::getProperty($hcc, 'appendPlugins');
24
        $this->assertCount(2, $plugins);
25
        $this->assertEquals($plugin1, $plugins[1]);
26
    }
27
28 View Code Duplication
    public function testAppendPluginMultiple()
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...
29
    {
30
        $hcc = new HttpClientConfigurator();
31
        $plugin0 = new HeaderAppendPlugin(['plugin0']);
32
        $plugin1 = new HeaderAppendPlugin(['plugin1']);
33
34
        $hcc->appendPlugin($plugin0, $plugin1);
35
        $plugins = NSA::getProperty($hcc, 'appendPlugins');
36
        $this->assertCount(2, $plugins);
37
        $this->assertEquals($plugin0, $plugins[0]);
38
        $this->assertEquals($plugin1, $plugins[1]);
39
    }
40
41 View Code Duplication
    public function testPrependPlugin()
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...
42
    {
43
        $hcc = new HttpClientConfigurator();
44
        $plugin0 = new HeaderAppendPlugin(['plugin0']);
45
46
        $hcc->prependPlugin($plugin0);
47
        $plugins = NSA::getProperty($hcc, 'prependPlugins');
48
        $this->assertCount(1, $plugins);
49
        $this->assertEquals($plugin0, $plugins[0]);
50
51
        $plugin1 = new HeaderAppendPlugin(['plugin1']);
52
        $hcc->prependPlugin($plugin1);
53
        $plugins = NSA::getProperty($hcc, 'prependPlugins');
54
        $this->assertCount(2, $plugins);
55
        $this->assertEquals($plugin1, $plugins[0]);
56
    }
57
58 View Code Duplication
    public function testPrependPluginMultiple()
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...
59
    {
60
        $hcc = new HttpClientConfigurator();
61
        $plugin0 = new HeaderAppendPlugin(['plugin0']);
62
        $plugin1 = new HeaderAppendPlugin(['plugin1']);
63
64
        $hcc->prependPlugin($plugin0, $plugin1);
65
        $plugins = NSA::getProperty($hcc, 'prependPlugins');
66
        $this->assertCount(2, $plugins);
67
        $this->assertEquals($plugin0, $plugins[0]);
68
        $this->assertEquals($plugin1, $plugins[1]);
69
    }
70
}
71