AlreadyExtractCommandTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A testIfCommandHaveExpectedBehavior() 0 13 1
A testIfCommandHaveExpectedBehaviorWithExtractDir() 0 13 1
A testIfCommandHaveExpectedBehaviorIfDirectoryIsBad() 0 9 1
1
<?php
2
3
namespace AlreadyExtract\Command;
4
5
use AlreadyExtract\Application\Application;
6
use Symfony\Component\Console\Tester\CommandTester;
7
8
class AlreadyExtractCommandTest extends \PHPUnit_Framework_TestCase
9
{
10
    protected $archivesDir;
11
12
    public function __construct()
13
    {
14
        $this->archivesDir = __DIR__ . '/../../fixtures/zip/';
15
    }
16
17
    public function testIfCommandHaveExpectedBehavior()
18
    {
19
        $application = new Application();
20
21
        $command = $application->find('already-extract');
22
23
        $commandTester = new CommandTester($command);
24
        $commandTester->execute(array('path' => $this->archivesDir));
25
26
        $this->assertRegExp('#Error: file (.*)/c.zip might be not extracted#', $commandTester->getDisplay());
27
        $this->assertRegExp('#Warning: file (.*)/b.zip looks weird#', $commandTester->getDisplay());
28
        $this->assertRegExp('#Warnings: 1 Errors: 1#', $commandTester->getDisplay());
29
    }
30
31
    public function testIfCommandHaveExpectedBehaviorWithExtractDir()
32
    {
33
        $application = new Application();
34
35
        $command = $application->find('already-extract');
36
37
        $commandTester = new CommandTester($command);
38
        $commandTester->execute(array('path' => $this->archivesDir, 'path-extracted' => $this->archivesDir));
39
40
        $this->assertRegExp('#Error: file (.*)/c.zip might be not extracted#', $commandTester->getDisplay());
41
        $this->assertRegExp('#Warning: file (.*)/b.zip looks weird#', $commandTester->getDisplay());
42
        $this->assertRegExp('#Warnings: 1 Errors: 1#', $commandTester->getDisplay());
43
    }
44
45
    /**
46
     * @expectedException \Exception
47
     */
48
    public function testIfCommandHaveExpectedBehaviorIfDirectoryIsBad()
49
    {
50
        $application = new Application();
51
52
        $command = $application->find('already-exist');
53
54
        $commandTester = new CommandTester($command);
55
        $commandTester->execute(array('path' => 'null'));
56
    }
57
}
58