|
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
|
|
|
|