Completed
Pull Request — master (#354)
by Strahinja
05:23
created

CompileTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 5
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 10 1
B testIgnorePaths() 0 22 4
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