Passed
Pull Request — master (#50)
by Marco
02:46
created

RevisionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidRevisionProvider() 0 7 1
A testFromSha1WithValidSha1() 0 5 1
A testInvalidSha1Rejected() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\BackwardCompatibility\Git;
6
7
use InvalidArgumentException;
8
use PHPUnit\Framework\TestCase;
9
use Roave\BackwardCompatibility\Git\Revision;
10
use function sha1;
11
use function str_repeat;
12
use function uniqid;
13
14
/**
15
 * @covers \Roave\BackwardCompatibility\Git\Revision
16
 */
17
final class RevisionTest extends TestCase
18
{
19
    public function testFromSha1WithValidSha1() : void
20
    {
21
        $sha1 = sha1(uniqid('sha1', true));
22
23
        self::assertSame($sha1, (string) Revision::fromSha1($sha1));
24
    }
25
26
    /**
27
     * @return string[][]
28
     */
29
    public function invalidRevisionProvider() : array
30
    {
31
        return [
32
            [''],
33
            ['a'],
34
            [str_repeat('a', 39)],
35
            [str_repeat('a', 41)],
36
        ];
37
    }
38
39
    /**
40
     * @dataProvider invalidRevisionProvider
41
     */
42
    public function testInvalidSha1Rejected(string $invalidRevision) : void
43
    {
44
        $this->expectException(InvalidArgumentException::class);
45
        Revision::fromSha1($invalidRevision);
46
    }
47
}
48