DiffCommandTest::testDiff()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
 * DiffCommandTest
20
 *
21
 * @author Matteo Giachino <[email protected]>
22
 */
23
24
class DiffCommandTest extends TestCase
25
{
26
    /**
27
     * @var \GitElephant\Command\DiffCommand
28
     */
29
    private $diffCommand;
30
31
    /**
32
     * set up
33
     */
34
    public function setUp(): void
35
    {
36
        $this->initRepository();
37
        $this->getRepository()->init();
38
        $this->addFile('foo');
39
        $this->getRepository()->commit('first commit', true);
40
        $this->diffCommand = new DiffCommand();
41
    }
42
43
    /**
44
     * diff test
45
     */
46
    public function testDiff(): void
47
    {
48
        $commit = $this->getRepository()->init()->getCommit();
49
        $this->assertEquals(
50
            DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' 'HEAD^..HEAD'",
51
            $this->diffCommand->diff('HEAD')
0 ignored issues
show
Documentation introduced by
'HEAD' is of type string, but the function expects a object<GitElephant\Objects\TreeishInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
52
        );
53
        $this->assertEquals(
54
            DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' 'branch2..HEAD' -- 'foo'",
55
            $this->diffCommand->diff('HEAD', 'branch2', 'foo')
0 ignored issues
show
Documentation introduced by
'HEAD' is of type string, but the function expects a object<GitElephant\Objects\TreeishInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'branch2' is of type string, but the function expects a object<GitElephant\Objects\TreeishInterface>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
        );
57
        $this->assertEquals(
58
            sprintf(
59
                DiffCommand::DIFF_COMMAND . " '--full-index' '--no-color' '--no-ext-diff' '-M' '--dst-prefix=DST/' '--src-prefix=SRC/' '%s^..%s'",
60
                $commit->getSha(),
61
                $commit->getSha()
62
            ),
63
            $this->diffCommand->diff($commit)
64
        );
65
    }
66
}
67