1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace uuf6429\ElderBrother; |
4
|
|
|
|
5
|
|
|
class GitTest extends BaseProjectTest |
6
|
|
|
{ |
7
|
|
|
public function setUp() |
8
|
|
|
{ |
9
|
|
|
$this->markTestSkipped('To be enabled when git (un)install works.'); |
10
|
|
|
parent::setUp(); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
public function testInstallation() |
14
|
|
|
{ |
15
|
|
|
$this->assertCommandSuccessful('git init'); |
16
|
|
|
$this->assertCommandSuccessful(self::getEbCmd() . 'install'); |
17
|
|
|
|
18
|
|
|
// TODO ensure git hook is as expected |
|
|
|
|
19
|
|
|
|
20
|
|
|
$config = sprintf( |
21
|
|
|
'<%s return [%s => [%s]];', |
22
|
|
|
'?php', |
23
|
|
|
Event\Git::class . '::PRE_COMMIT', |
24
|
|
|
sprintf( |
25
|
|
|
'new %s( %s::getAdded()->name("/.php$/") )', |
26
|
|
|
Action\PhpLinter::class, |
27
|
|
|
Change\GitChangeSet::class |
28
|
|
|
) |
29
|
|
|
); |
30
|
|
|
$this->assertNotFalse(file_put_contents('.brother.php', $config)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @depends testInstallation |
35
|
|
|
*/ |
36
|
|
|
public function testCommitingGoodCode() |
37
|
|
|
{ |
38
|
|
|
$this->assertNotFalse(file_put_contents('test1.php', '<php echo "Hi!";')); |
39
|
|
|
|
40
|
|
|
$this->assertCommandSuccessful('git add .'); |
41
|
|
|
$this->assertCommandSuccessful('git commit -m test1'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @depends testCommitingGoodCode |
46
|
|
|
*/ |
47
|
|
|
public function testCommitingBadCode() |
48
|
|
|
{ |
49
|
|
|
$this->assertNotFalse(file_put_contents('test2.php', '<php ec ho')); |
50
|
|
|
|
51
|
|
|
$this->assertCommandSuccessful('git add .'); |
52
|
|
|
$this->assertCommand('git commit -m test2', 1, ['zxvzxz']); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @depends testCommitingGoodCode |
57
|
|
|
* @depends testCommitingBadCode |
58
|
|
|
*/ |
59
|
|
|
public function testUninstallation() |
60
|
|
|
{ |
61
|
|
|
$this->assertCommandSuccessful(self::getEbCmd() . 'uninstall'); |
62
|
|
|
|
63
|
|
|
// TODO ensure git hook is as expected |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|