UuidTest::testGetSlug()   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 AbterPhp\Framework\Validation\Rules;
6
7
use PHPUnit\Framework\TestCase;
8
9
class UuidTest extends TestCase
10
{
11
    /** @var Uuid - System Under Test */
12
    protected Uuid $sut;
13
14
    public function setUp(): void
15
    {
16
        parent::setUp();
17
18
        $this->sut = new Uuid();
19
    }
20
21
    /**
22
     * @return array
23
     */
24
    public function passesProvider(): array
25
    {
26
        return [
27
            'empty'      => ['', [], false],
28
            'uuid4-1'    => ['631022a3-0452-4bb4-8105-ce4f0a37be94', [], true],
29
            'uuid4-2'    => ['c513d8b7-79fb-4a65-8f6c-1454068b77d2', [], true],
30
            'uuid4-3'    => ['5b4789fc-a4db-4724-b2f1-ea5e57db3f43', [], true],
31
            'uuid4-4'    => ['736b183e-6ec3-4556-996a-3e3ee5de1608', [], true],
32
            'uuid4-5'    => ['022bfa5a-af6f-48c1-8854-048fa66ff905', [], true],
33
            'uuid4-6'    => ['b3e0f1e7-3ad0-4794-ac9b-db915ad6bda2', [], true],
34
            'uuid4-7'    => ['65da83c8-ec37-4676-9578-996cb11f7bc8', [], true],
35
            'uuid4-8'    => ['03188083-cb1b-4059-9737-704aa93f39b5', [], true],
36
            'uuid4-9'    => ['f0bad66a-3485-451a-9b66-42cf0cb3389d', [], true],
37
            'uuid4-10'   => ['c654b41b-516b-47e0-b674-988ce1eced42', [], true],
38
            'short'      => ['c654b41b-516b-47e0-b674-988ce1eced4', [], false],
39
            'long'       => ['c654b41b-516b-47e0-b674-988ce1eced422', [], false],
40
            'wrong-dash' => ['c654b41-b516b-47e0-b674-988ce1eced42', [], false],
41
        ];
42
    }
43
44
    /**
45
     * @dataProvider passesProvider
46
     *
47
     * @param       $value
48
     * @param array $allValues
49
     * @param bool  $expectedResult
50
     */
51
    public function testPasses($value, array $allValues, bool $expectedResult): void
52
    {
53
        $actualResult = $this->sut->passes($value, $allValues);
54
55
        $this->assertEquals($expectedResult, $actualResult);
56
    }
57
58
    public function testGetSlug(): void
59
    {
60
        $actualResult = $this->sut->getSlug();
61
62
        $this->assertSame('uuid', $actualResult);
63
    }
64
}
65