Completed
Push — master ( 794f3d...1e9726 )
by diego
07:00
created

BaseCommandTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A setUpCommandTesterFor() 0 10 1
1
<?php
2
namespace Diego\Grepper\Tests\Command;
3
4
use Diego\Grepper\App;
5
use org\bovigo\vfs\vfsStream;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
/**
11
 * Class BaseCommandTestCase
12
 */
13
abstract class BaseCommandTestCase extends TestCase
14
{
15
    public function setUp()
16
    {
17
        vfsStream::setup('root', null, [
18
            'input.csv' => '123' . PHP_EOL . '456' . PHP_EOL . 'asdf',
19
            'output.csv' => ''
20
        ]);
21
    }
22
23
    /**
24
     * @param string $name
25
     * @param Command $class
26
     *
27
     * @return CommandTester
28
     */
29
    public function setUpCommandTesterFor($name, $class)
30
    {
31
        $app = new App;
32
        $command = new $class;
33
        $command->setApplication($app);
34
        $command = $app->find($name);
35
36
        $tester = new CommandTester($command);
37
        return $tester;
38
    }
39
}
40