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

CompileTest::testIgnorePaths()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 14
nc 4
nop 0
dl 0
loc 22
rs 8.9197
c 0
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