Passed
Push — master ( 1eca82...577019 )
by Sebastian
03:18 queued 45s
created

ShellTest::testTemplateExtExecutable()   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
eloc 9
c 1
b 0
f 0
dl 0
loc 13
rs 9.9666
cc 1
nc 1
nop 0
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