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

GitProjectTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 61
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testInstallation() 0 19 1
A testCommitingGoodCode() 0 7 1
A testCommitingBadCode() 0 7 1
A testUninstallation() 0 6 1
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