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

BaseCommandTestCase::setUpCommandTesterFor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
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