DiffTreeCommandTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testRootDiff() 0 14 1
1
<?php
2
3
/**
4
 * This file is part of the GitElephant package.
5
 *
6
 * (c) Matteo Giachino <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Just for fun...
12
 */
13
14
namespace GitElephant\Command;
15
16
use GitElephant\TestCase;
17
18
/**
19
 * DiffTreeCommandTest
20
 *
21
 * @author Matteo Giachino <[email protected]>
22
 */
23
24
class DiffTreeCommandTest extends TestCase
25
{
26
    /**
27
     * set up
28
     */
29
    public function setUp(): void
30
    {
31
        $this->initRepository();
32
        $this->getRepository()->init();
33
        $this->addFile('foo');
34
        $this->getRepository()->commit('first commit', true);
35
    }
36
37
    /**
38
     * set up
39
     */
40
    public function testRootDiff(): void
41
    {
42
        $dtc = DiffTreeCommand::getInstance();
43
        $commit = $this->getRepository()->getCommit();
44
        $command = $dtc->rootDiff($commit);
45
        $this->assertEquals(
46
            sprintf("diff-tree '--cc' '--root' '--dst-prefix=DST/' '--src-prefix=SRC/' '%s'", $commit),
47
            $command
48
        );
49
        $this->addFile('test');
50
        $this->getRepository()->commit('test commit', true);
51
        $this->expectException('InvalidArgumentException');
52
        $this->fail($dtc->rootDiff($this->getRepository()->getCommit()));
53
    }
54
}
55