testFromPathRejectsNonGitDirectory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
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