Passed
Push — main ( 6c9a60...f17c77 )
by Sebastian
13:38
created

InfoTest::testDisplaySingleHook()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.9666
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console\Command;
13
14
use CaptainHook\App\Console\Runtime\Resolver;
15
use CaptainHook\App\Git\DummyRepo;
16
use CaptainHook\App\Runner\Config\Reader;
17
use Exception;
18
use org\bovigo\vfs\vfsStream;
19
use PHPUnit\Framework\TestCase;
20
use Symfony\Component\Console\Input\ArrayInput;
21
use Symfony\Component\Console\Output\NullOutput;
22
23
class InfoTest extends TestCase
24
{
25
    public function testFailsWithoutConfig(): void
26
    {
27
        $this->expectException(Exception::class);
28
29
        $resolver = new Resolver();
30
        $output   = new NullOutput();
31
        $input    = new ArrayInput([
32
            'hook'            => 'pre-commit',
33
            '--configuration' => 'foo',
34
        ]);
35
36
        $install = new Info($resolver);
37
        $install->run($input, $output);
38
    }
39
40
    public function testDisplaySingleHook(): void
41
    {
42
        $dummyRepo = new DummyRepo();
43
        $resolver  = new Resolver();
44
        $output    = new NullOutput();
45
        $input     = new ArrayInput([
46
            'hook' => 'pre-commit',
47
            '-c'   => CH_PATH_FILES . '/config/valid.json',
48
            '-g'   => $dummyRepo->getRoot() . '/.git',
49
        ]);
50
51
        $add = new Info($resolver);
52
        $this->assertEquals(0, $add->run($input, $output));
53
    }
54
}
55