Completed
Push — master ( a95a96...37a9eb )
by Christian
02:10
created

GitProjectTest::setUp()   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
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace uuf6429\ElderBrother;
4
5
class GitProjectTest 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
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
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
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
64
    }
65
}
66