Completed
Pull Request — master (#14)
by ophelie
02:25
created

ComposeManagerIpsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 1
dl 58
loc 58
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 6 6 1
A testIps() 8 8 1
A testIpsWithOneComposeFileSpecified() 7 7 1
A testIpsWithTwoComposeFilesSpecified() 7 7 1
A testIpsWithprojectOption() 11 11 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 DockerCompose\Tests\Manager;
4
5
use PHPUnit_Framework_TestCase;
6
use DockerCompose\ComposeFile;
7
use DockerCompose\ComposeFileCollection;
8
9
10 View Code Duplication
class ComposeManagerIpsTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    public function setUp()
13
    {
14
        $this->mockedManager = $this->getMockBuilder('\DockerCompose\Manager\ComposeManager')
15
            ->setMethods(['execute'])
16
            ->getMock();
17
    }
18
19
    /**
20
     * Test simple get ips containers
21
     */
22
    public function testIps()
23
    {
24
        $this->mockedManager
25
            ->method('execute')
26
            ->willReturn(array('output' => 'ok', 'code' => 0));
27
28
        $this->assertEquals($this->mockedManager->ips(), 'ok');
29
    }
30
31
    /**
32
     * Test start success with one compose file
33
     */
34
    public function testIpsWithOneComposeFileSpecified()
35
    {
36
        $this->mockedManager
37
        ->method('execute')
38
        ->willReturn(array('output' => 'ok', 'code' => 0));
39
        $this->assertEquals($this->mockedManager->ips('docker-compose.test.yml'), 'ok');
40
    }
41
42
    /**
43
     * Test ips success with two compose files
44
     */
45
    public function testIpsWithTwoComposeFilesSpecified()
46
    {
47
        $this->mockedManager
48
            ->method('execute')
49
            ->willReturn(array('output' => 'ok', 'code' => 0));
50
        $this->assertEquals($this->mockedManager->ips(['docker-compose.yml', 'docker-compose.test.yml']), 'ok');
51
    }
52
53
    /**
54
     * Test ips with project option
55
     */
56
    public function testIpsWithprojectOption()
57
    {
58
        $composeFiles = new ComposeFileCollection(['docker-compose.test.yml']);
59
        $composeFiles->setProjectName('unittest');
60
61
        $this->mockedManager
62
            ->method('execute')
63
            ->willReturn(array('output' => 'ok', 'code' => 0));
64
65
        $this->assertEquals($this->mockedManager->ips($composeFiles), 'ok');
66
    }
67
}
68