|
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
|
|
|
|