Passed
Push — master ( e4e2c9...124fdd )
by Gabriel
01:32
created

UuidTest::test_uuid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Nip\Utility\Tests;
4
5
use Nip\Utility\Uuid;
6
7
/**
8
 * Class UuidTest
9
 * @package Nip\Utility\Tests
10
 */
11
class UuidTest extends AbstractTest
12
{
13
14
    public function test_uuid()
15
    {
16
        $uuid = Uuid::uuid();
17
        self::assertIsObject($uuid);
18
        $uuid = (string) $uuid;
19
        self::assertIsString($uuid);
20
        self::assertTrue(Uuid::isValid($uuid));
21
        self::assertSame(36, strlen($uuid));
22
    }
23
24
    /**
25
     * @dataProvider validUuidList
26
     * @param $uuid
27
     */
28
    public function test_isValid_validList($uuid)
29
    {
30
        static::assertTrue(Uuid::isValid($uuid));
31
    }
32
33
    /**
34
     * @dataProvider invalidUuidList
35
     * @param $uuid
36
     */
37
    public function test_isValid_invalidList($uuid)
38
    {
39
        static::assertFalse(Uuid::isValid($uuid));
40
    }
41
42
    /**
43
     * @return \string[][]
44
     */
45
    public function validUuidList()
46
    {
47
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(array('a0a2...E1-9B21-0800200C9A66')) returns the type array<integer,array<integer,string>> which is incompatible with the documented return type array<mixed,string[]>.
Loading history...
48
            ['a0a2a2d2-0b87-4a18-83f2-2529882be2de'],
49
            ['145a1e72-d11d-11e8-a8d5-f2801f1b9fd1'],
50
            ['00000000-0000-0000-0000-000000000000'],
51
            ['e60d3f48-95d7-4d8d-aad0-856f29a27da2'],
52
            ['ff6f8cb0-c57d-11e1-9b21-0800200c9a66'],
53
            ['ff6f8cb0-c57d-21e1-9b21-0800200c9a66'],
54
            ['ff6f8cb0-c57d-31e1-9b21-0800200c9a66'],
55
            ['ff6f8cb0-c57d-41e1-9b21-0800200c9a66'],
56
            ['ff6f8cb0-c57d-51e1-9b21-0800200c9a66'],
57
            ['FF6F8CB0-C57D-11E1-9B21-0800200C9A66'],
58
        ];
59
    }
60
61
    /**
62
     * @return \string[][]
63
     */
64
    public function invalidUuidList()
65
    {
66
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(array('not ...e1-9b21-0800200c9a66')) returns the type array<integer,array<integer,string>> which is incompatible with the documented return type array<mixed,string[]>.
Loading history...
67
            ['not a valid uuid so we can test this'],
68
            ['zf6f8cb0-c57d-11e1-9b21-0800200c9a66'],
69
            ['145a1e72-d11d-11e8-a8d5-f2801f1b9fd1' . PHP_EOL],
70
            ['145a1e72-d11d-11e8-a8d5-f2801f1b9fd1 '],
71
            [' 145a1e72-d11d-11e8-a8d5-f2801f1b9fd1'],
72
            ['145a1e72-d11d-11e8-a8d5-f2z01f1b9fd1'],
73
            ['3f6f8cb0-c57d-11e1-9b21-0800200c9a6'],
74
            ['af6f8cb-c57d-11e1-9b21-0800200c9a66'],
75
            ['af6f8cb0c57d11e19b210800200c9a66'],
76
            ['ff6f8cb0-c57da-51e1-9b21-0800200c9a66'],
77
        ];
78
    }
79
}
80