19declare(strict_types=1);
21require_once(
"vendor/composer/vendor/autoload.php");
23use PHPUnit\Framework\TestCase;
26use Ramsey\Uuid\Exception\InvalidUuidStringException;
30 private const VALID_UUID4 =
'/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/';
32 private const UUID4 =
'f47ac10b-58cc-4372-a567-0e02b2c3d479';
33 private const NO_UUID =
'lorem ipsum dolor';
35 #[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
41 #[\PHPUnit\Framework\Attributes\Depends('test_init')]
45 $uuid = $factory->uuid4();
47 $this->assertMatchesRegularExpression(self::VALID_UUID4,
$uuid->toString());
50 #[\PHPUnit\Framework\Attributes\Depends('test_init')]
54 $uuid = $factory->uuid4AsString();
56 $this->assertIsString(
$uuid);
57 $this->assertMatchesRegularExpression(self::VALID_UUID4,
$uuid);
64 #[\PHPUnit\Framework\Attributes\Depends('test_init')]
70 'cdefba47-4fc6-3904-99e9-989195f87f2c',
71 $factory->uuid3AsString(
'6ba7b810-9dad-11d1-80b4-00c04fd430c8',
'www.ilias.de')
75 'd60304bc-9cb8-3988-9fa1-e6953cc506e7',
76 $factory->uuid3AsString(
'0123456789abcdef0123456789abcdef',
'12-34')
79 'cdefba47-4fc6-3904-99e9-989195f87f2c',
80 $factory->uuid3($factory->fromString(
'6ba7b810-9dad-11d1-80b4-00c04fd430c8'),
'www.ilias.de')->toString()
84 #[\PHPUnit\Framework\Attributes\Depends('test_init')]
88 $uuid = $factory->fromString(self::UUID4);
90 $this->assertMatchesRegularExpression(self::VALID_UUID4,
$uuid->toString());
91 $this->assertEquals(self::UUID4,
$uuid->toString());
94 #[\PHPUnit\Framework\Attributes\Depends('test_init')]
97 $this->expectException(InvalidUuidStringException::class);
100 $factory->fromString(self::NO_UUID);
test_from_illegal_string()
test_uuid3_is_stable()
Name-based UUIDs must never change: they are stored and compared, e.g.