|
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 sebastianfeldmann\CaptainHook\Hook\Message; |
|
11
|
|
|
|
|
12
|
|
|
use sebastianfeldmann\CaptainHook\Config; |
|
13
|
|
|
use sebastianfeldmann\CaptainHook\Console\IO\NullIO; |
|
14
|
|
|
use sebastianfeldmann\CaptainHook\Git\CommitMessage; |
|
15
|
|
|
use sebastianfeldmann\CaptainHook\Git\DummyRepo; |
|
16
|
|
|
use sebastianfeldmann\CaptainHook\Git\Repository; |
|
17
|
|
|
|
|
18
|
|
|
class BeamsTest extends \PHPUnit_Framework_TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var \sebastianfeldmann\CaptainHook\Git\DummyRepo |
|
22
|
|
|
*/ |
|
23
|
|
|
private $repo; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Setup dummy repo. |
|
27
|
|
|
*/ |
|
28
|
|
|
public function setUp() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->repo = new DummyRepo(); |
|
31
|
|
|
$this->repo->setup(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Cleanup dummy repo. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function tearDown() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->repo->cleanup(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Tests Beams::execute |
|
44
|
|
|
*/ |
|
45
|
|
|
public function testExecute() |
|
46
|
|
|
{ |
|
47
|
|
|
$io = new NullIO(); |
|
48
|
|
|
$config = new Config(HMU_PATH_FILES . '/captainhook.json'); |
|
49
|
|
|
$action = new Config\Action('php', '\\sebastianfeldmann\\CaptainHook\\Hook\\Message\\Beams'); |
|
50
|
|
|
$repo = new Repository($this->repo->getPath()); |
|
51
|
|
|
$repo->setCommitMsg(new CommitMessage('Foo bar baz')); |
|
52
|
|
|
|
|
53
|
|
|
$standard = new Beams(); |
|
54
|
|
|
$standard->execute($config, $io, $repo, $action); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Tests Beams::execute |
|
59
|
|
|
* |
|
60
|
|
|
* @expectedException \Exception |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testExecuteFail() |
|
63
|
|
|
{ |
|
64
|
|
|
$io = new NullIO(); |
|
65
|
|
|
$config = new Config(HMU_PATH_FILES . '/captainhook.json'); |
|
66
|
|
|
$action = new Config\Action('php', '\\sebastianfeldmann\\CaptainHook\\Hook\\Message\\Beams'); |
|
67
|
|
|
$repo = new Repository($this->repo->getPath()); |
|
68
|
|
|
$repo->setCommitMsg(new CommitMessage('foo bar baz.')); |
|
69
|
|
|
|
|
70
|
|
|
$standard = new Beams(); |
|
71
|
|
|
$standard->execute($config, $io, $repo, $action); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|