testIfCommandHaveExpectedBehaviorIfDirectoryIsBad()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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