Passed
Push — master ( b649b5...b34030 )
by Sebastian
04:07
created

RepositoryTest::testGetCommitMessageFail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace CaptainHook\Git;
11
12
class RepositoryTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var \CaptainHook\Git\DummyRepo
16
     */
17
    private $repo;
18
19
    /**
20
     * Setup dummy repo.
21
     */
22
    public function setUp()
23
    {
24
        $this->repo = new DummyRepo();
25
        $this->repo->setup();
26
    }
27
28
    /**
29
     * Cleanup dummy repo.
30
     */
31
    public function tearDown()
32
    {
33
        $this->repo->cleanup();
34
    }
35
36
    /**
37
     * Tests Repository::__construct
38
     *
39
     * @expectedException \Exception
40
     */
41
    public function testInvalidRepository()
42
    {
43
        $repository = new Repository('invalidGitRepo');
44
        $this->assertFalse(is_a($repository, '\\CaptainHook\\Git\\Repository'));
45
    }
46
47
    /**
48
     * Tests Repository::getHooks
49
     */
50
    public function testGetHooksDir()
51
    {
52
        $repository = new Repository($this->repo->getPath());
53
        $this->assertEquals($this->repo->getPath() . '/.git/hooks', $repository->getHooksDir());
54
    }
55
56
    /**
57
     * Tests Repository::hookExists
58
     */
59
    public function testHookExists()
60
    {
61
        $this->repo->touchHook('pre-commit');
62
63
        $repository = new Repository($this->repo->getPath());
64
65
        $this->assertTrue($repository->hookExists('pre-commit'));
66
        $this->assertFalse($repository->hookExists('pre-push'));
67
    }
68
69
    /**
70
     * Tests Repository::getCommitMsg
71
     *
72
     * @expectedException \Exception
73
     */
74
    public function testGetCommitMessageFail()
75
    {
76
        $repository = new Repository($this->repo->getPath());
77
        $repository->getCommitMsg();
78
    }
79
}
80