File: StaticNodeProviderTest.php

package info (click to toggle)
php-ramsey-uuid 4.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 2,124 kB
  • sloc: php: 13,359; xml: 194; python: 54; makefile: 16
file content (58 lines) | stat: -rw-r--r-- 1,669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

declare(strict_types=1);

namespace Ramsey\Uuid\Test\Provider\Node;

use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Provider\Node\StaticNodeProvider;
use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Type\Hexadecimal;

class StaticNodeProviderTest extends TestCase
{
    /**
     * @dataProvider provideNodeForTest
     */
    public function testStaticNode(Hexadecimal $node, string $expectedNode): void
    {
        $staticNode = new StaticNodeProvider($node);

        $this->assertSame($expectedNode, $staticNode->getNode()->toString());
    }

    /**
     * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification
     */
    public function provideNodeForTest(): array
    {
        return [
            [
                'node' => new Hexadecimal('0'),
                'expectedNode' => '010000000000',
            ],
            [
                'node' => new Hexadecimal('1'),
                'expectedNode' => '010000000001',
            ],
            [
                'node' => new Hexadecimal('f2ffffffffff'),
                'expectedNode' => 'f3ffffffffff',
            ],
            [
                'node' => new Hexadecimal('ffffffffffff'),
                'expectedNode' => 'ffffffffffff',
            ],
        ];
    }

    public function testStaticNodeThrowsExceptionForTooLongNode(): void
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage(
            'Static node value cannot be greater than 12 hexadecimal characters'
        );

        new StaticNodeProvider(new Hexadecimal('1000000000000'));
    }
}