Completed
Pull Request — master (#354)
by Strahinja
03:19
created

CompileTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA\Command;
4
5
use Tests\PHPSA\TestCase;
6
use PHPSA\Application;
7
use Symfony\Component\Console\Tester\CommandTester;
8
9
class CompileTest extends TestCase
10
{
11
    public function testExecute()
12
    {
13
        $application = new Application();
14
15
        $command = $application->find('compile');
16
        $commandTester = new CommandTester($command);
17
        $commandTester->execute(['command'  => $command->getName(), 'path' => 'tests/PHPSA/Command/']);
18
19
        self::assertContains('Memory usage:', $commandTester->getDisplay());
20
    }
21
    // simple as it is
22
    public function testIgnorePaths()
23
    {
24
        $ignore = ["/vendor"];
25
        $files = [
26
            "/vendor/path/to/1.php",
27
            "/vendor/path/to/2.php",
28
            "/vendor/path/to/3.php",
29
            "/app/path/to/model.php",
30
        ];
31
32
        $skip = 0;
33
        foreach ($files as $file) {
34
            foreach ($ignore as $item) {
35
                if (preg_match("#$item#", $file)) {
36
                    $skip++;
37
                    break;
38
                }
39
            }
40
        }
41
42
        $this->assertEquals($skip, 3);
43
    }
44
}
45