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'));
}
}
|