1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DockerCompose\Tests\Manager; |
4
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
6
|
|
|
use DockerCompose\ComposeFile; |
7
|
|
|
use DockerCompose\ComposeFileCollection; |
8
|
|
|
use DockerCompose\Manager\ComposeManager; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class ComposeManagerIntegrationTest extends PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
public function setUp() |
14
|
|
|
{ |
15
|
|
|
$this->manager = new ComposeManager(); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Test simple start without error |
20
|
|
|
* |
21
|
|
|
* @expectedException \DockerCompose\Exception\ComposeFileNotFoundException |
22
|
|
|
*/ |
23
|
|
|
public function testThrowComposeFileNotFoundException() |
24
|
|
|
{ |
25
|
|
|
$this->assertEquals($this->manager->start(), ''); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Test simple start, ps, stop and rm without error |
30
|
|
|
* |
31
|
|
|
*/ |
32
|
|
|
public function testSuccess() |
33
|
|
|
{ |
34
|
|
|
$this->assertEquals($this->manager->start('/var/www/docker-compose-test.yml'), ''); |
35
|
|
|
$result = $this->manager->ps('/var/www/docker-compose-test.yml'); |
36
|
|
|
$this->assertEquals(strpos($result, 'www_test_1'), 118); |
37
|
|
|
$this->assertEquals($this->manager->stop('/var/www/docker-compose-test.yml'), ''); |
38
|
|
|
$this->assertEquals($this->manager->remove('/var/www/docker-compose-test.yml'), 'Going to remove www_test_1'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Test simple run without error |
43
|
|
|
* |
44
|
|
|
*/ |
45
|
|
View Code Duplication |
public function testRunSuccess() |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
$composeFiles = new ComposeFileCollection(['/var/www/docker-compose-test.yml']); |
48
|
|
|
$composeFiles->setProjectName('unittest'); |
49
|
|
|
|
50
|
|
|
$this->assertEquals($this->manager->run('test', 'echo test', $composeFiles), "test"); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Test run |
55
|
|
|
* @expectedException \DockerCompose\Exception\NoSuchServiceException |
56
|
|
|
*/ |
57
|
|
View Code Duplication |
public function testrunThrowNoSuchServiceException() |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
$composeFiles = new ComposeFileCollection(['/var/www/docker-compose-test.yml']); |
60
|
|
|
$composeFiles->setProjectName('unittest'); |
61
|
|
|
|
62
|
|
|
$this->manager->run('failedservice', 'echo test', $composeFiles); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
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.