ComposeManagerRunTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testrun() 0 5 1
A testrunThrowNoSuchServiceException() 0 8 1
A testRuntWithprojectOption() 0 8 1
1
<?php
2
3
namespace DockerCompose\Tests\mockedManager;
4
5
use PHPUnit_Framework_TestCase;
6
use DockerCompose\ComposeFile;
7
use DockerCompose\ComposeFileCollection;
8
use DockerCompose\Manager\ComposeManager;
9
10
11
class ComposeManagerRunTest extends PHPUnit_Framework_TestCase
12
{
13
    public function setUp()
14
    {
15
        $this->mockedManager = $this->getMockBuilder('\DockerCompose\Manager\ComposeManager')
16
            ->setMethods(['execute'])
17
            ->getMock();
18
    }
19
20
    /**
21
     * Test run
22
     */
23
    public function testrun()
24
    {
25
        $this->mockedManager->method('execute')->willReturn(array('output' => 'ok', 'code' => 0));
26
        $this->assertEquals($this->mockedManager->run('test', 'mycommand'), 'ok');
27
    }
28
29
    /**
30
     * Test run
31
     * @expectedException \DockerCompose\Exception\NoSuchServiceException
32
     */
33
    public function testrunThrowNoSuchServiceException()
34
    {
35
        $composeFiles = new ComposeFileCollection(['/var/www/docker-compose-test.yml']);
36
        $composeFiles->setProjectName('unittest');
37
38
        $this->mockedManager->method('execute')->willReturn(array('output' => 'No such service : failedservice', 'code' => 1));
39
        $this->mockedManager->run('failedservice', 'echo test', $composeFiles);
40
    }
41
42
    /**
43
     * Test run with project
44
     */
45
    public function testRuntWithprojectOption()
46
    {
47
        $composeFiles = new ComposeFileCollection(['/var/www/docker-compose-test.yml']);
48
        $composeFiles->setProjectName('unittest');
49
50
        $this->mockedManager->method('execute')->willReturn(array('output' => 'test', 'code' => 0));
51
        $this->assertEquals($this->mockedManager->run('test', 'echo test', $composeFiles), "test");
52
    }
53
}
54