GitCliWrapperTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 5
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetGitShaCommandFails() 0 6 1
A testGitDiffCommandFails() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Tests\Unit\Plugins\GitDiffHistoryAnalyser\internal;
6
7
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Common\ProjectRoot;
8
use DaveLiddament\StaticAnalysisResultsBaseliner\Plugins\GitDiffHistoryAnalyser\GitCommit;
9
use DaveLiddament\StaticAnalysisResultsBaseliner\Plugins\GitDiffHistoryAnalyser\GitException;
10
use DaveLiddament\StaticAnalysisResultsBaseliner\Plugins\GitDiffHistoryAnalyser\internal\GitCliWrapper;
11
use PHPUnit\Framework\TestCase;
12
13
final class GitCliWrapperTest extends TestCase
14
{
15
    public function testGitDiffCommandFails(): void
16
    {
17
        $projectRoot = ProjectRoot::fromCurrentWorkingDirectory(__DIR__);
18
        $gitCliWrapper = new GitCliWrapper();
19
        $nonExistentGitSha = new GitCommit('0000000000000000000000000000000000000000');
20
        $this->expectException(GitException::class);
21
        $gitCliWrapper->getGitDiff($projectRoot, $nonExistentGitSha);
22
    }
23
24
    public function testGetGitShaCommandFails(): void
25
    {
26
        $projectRoot = ProjectRoot::fromCurrentWorkingDirectory(__DIR__);
27
        $gitCliWrapper = new GitCliWrapper();
28
        $this->expectException(GitException::class);
29
        $gitCliWrapper->getCurrentSha($projectRoot);
30
    }
31
}
32