CheckedOutRepositoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 27
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromPath() 0 11 1
A testFromPathRejectsNonGitDirectory() 0 5 1
A testFromPathRejectsNonExistingDirectory() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\Git;
6
7
use Assert\AssertionFailedException;
8
use PHPUnit\Framework\TestCase;
9
use Roave\BackwardCompatibility\Git\CheckedOutRepository;
10
use function Safe\mkdir;
11
use function Safe\rmdir;
12
use function sys_get_temp_dir;
13
use function uniqid;
14
15
/**
16
 * @covers \Roave\BackwardCompatibility\Git\CheckedOutRepository
17
 */
18
final class CheckedOutRepositoryTest extends TestCase
19
{
20
    public function testFromPath() : void
21
    {
22
        $path = sys_get_temp_dir() . '/' . uniqid('testPath', true);
23
        mkdir($path, 0777, true);
24
        mkdir($path . '/.git');
25
26
        $checkedOutRepository = CheckedOutRepository::fromPath($path);
27
        self::assertSame($path, (string) $checkedOutRepository);
28
29
        rmdir($path . '/.git');
30
        rmdir($path);
31
    }
32
33
    public function testFromPathRejectsNonGitDirectory() : void
34
    {
35
        $this->expectException(AssertionFailedException::class);
36
37
        CheckedOutRepository::fromPath(__DIR__);
38
    }
39
40
    public function testFromPathRejectsNonExistingDirectory() : void
41
    {
42
        $this->expectException(AssertionFailedException::class);
43
44
        CheckedOutRepository::fromPath(__DIR__ . '/non-existing');
45
    }
46
}
47