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\Hook\Template; |
13
|
|
|
|
14
|
|
|
use CaptainHook\App\CH; |
15
|
|
|
use CaptainHook\App\Console\IO\Mockery as IOMockery; |
16
|
|
|
use CaptainHook\App\Git\DummyRepo; |
17
|
|
|
use CaptainHook\App\Mockery as AppMockery; |
18
|
|
|
use Exception; |
19
|
|
|
use PHPUnit\Framework\TestCase; |
20
|
|
|
|
21
|
|
|
class InspectorTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
use IOMockery; |
24
|
|
|
use AppMockery; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Tests Inspector::inspect |
28
|
|
|
*/ |
29
|
|
|
public function testInspectValid(): void |
30
|
|
|
{ |
31
|
|
|
$io = $this->createIOMock(); |
32
|
|
|
$dummy = new DummyRepo(['hooks' => ['pre-push' => '# installed by CaptainHook ' . CH::MIN_REQ_INSTALLER]]); |
33
|
|
|
$repo = $this->createRepositoryMock($dummy->getRoot()); |
34
|
|
|
$repo->method('getHooksDir')->willReturn($dummy->getHookDir()); |
35
|
|
|
|
36
|
|
|
$inspector = new Inspector('pre-push', $io, $repo); |
37
|
|
|
$inspector->inspect(); |
38
|
|
|
|
39
|
|
|
$this->assertTrue(true); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Tests Inspector::inspect |
44
|
|
|
*/ |
45
|
|
|
public function testInspectInvalid(): void |
46
|
|
|
{ |
47
|
|
|
$this->expectException(Exception::class); |
48
|
|
|
|
49
|
|
|
$io = $this->createIOMock(); |
50
|
|
|
$dummy = new DummyRepo(['hooks' => ['pre-push' => '# installed by CaptainHook 3.10.4']]); |
51
|
|
|
$repo = $this->createRepositoryMock($dummy->getRoot()); |
52
|
|
|
$repo->method('getHooksDir')->willReturn($dummy->getHookDir()); |
53
|
|
|
|
54
|
|
|
$inspector = new Inspector('pre-push', $io, $repo); |
55
|
|
|
$inspector->inspect(); |
56
|
|
|
|
57
|
|
|
$this->assertTrue(true); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|