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\Local; |
13
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use SebastianFeldmann\Camino\Path\Directory; |
16
|
|
|
use SebastianFeldmann\Camino\Path\File; |
17
|
|
|
|
18
|
|
|
class ShellTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Tests Shell::getCode |
22
|
|
|
*/ |
23
|
|
|
public function testTemplate(): void |
24
|
|
|
{ |
25
|
|
|
$repo = new Directory('/foo/bar'); |
26
|
|
|
$config = new File('/foo/bar/captainhook.json'); |
27
|
|
|
$executable = new File('/foo/bar/vendor/bin/captainhook'); |
28
|
|
|
$bootstrap = 'vendor/autoload.php'; |
29
|
|
|
|
30
|
|
|
$template = new Shell($repo, $config, $executable, $bootstrap, false); |
31
|
|
|
$code = $template->getCode('commit-msg'); |
32
|
|
|
|
33
|
|
|
$this->assertStringContainsString('#!/usr/bin/sh', $code); |
34
|
|
|
$this->assertStringContainsString('commit-msg', $code); |
35
|
|
|
$this->assertStringContainsString('vendor/bin/captainhook', $code); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Tests Shell::getCode |
40
|
|
|
*/ |
41
|
|
|
public function testTemplateExtExecutable(): void |
42
|
|
|
{ |
43
|
|
|
$repo = new Directory('/foo/bar'); |
44
|
|
|
$config = new File('/foo/bar/captainhook.json'); |
45
|
|
|
$executable = new File('/usr/local/bin/captainhook'); |
46
|
|
|
$bootstrap = 'vendor/autoload.php'; |
47
|
|
|
|
48
|
|
|
$template = new Shell($repo, $config, $executable, $bootstrap, false); |
49
|
|
|
$code = $template->getCode('commit-msg'); |
50
|
|
|
|
51
|
|
|
$this->assertStringContainsString('#!/usr/bin/sh', $code); |
52
|
|
|
$this->assertStringContainsString('commit-msg', $code); |
53
|
|
|
$this->assertStringContainsString('/usr/local/bin/captainhook', $code); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|