ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UuidTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once("vendor/composer/vendor/autoload.php");
22 
27 
28 class UuidTest extends TestCase
29 {
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}$/';
31 
32  private const UUID4 = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';
33  private const NO_UUID = 'lorem ipsum dolor';
34 
38  public function test_init(): Factory
39  {
40  return new Factory();
41  }
42 
46  public function test_uuid4(): void
47  {
48  $factory = new Factory();
49  $uuid = $factory->uuid4();
50 
51  $this->assertMatchesRegularExpression(self::VALID_UUID4, $uuid->toString());
52  }
53 
57  public function test_uuid4_string(): void
58  {
59  $factory = new Factory();
60  $uuid = $factory->uuid4AsString();
61 
62  $this->assertIsString($uuid);
63  $this->assertMatchesRegularExpression(self::VALID_UUID4, $uuid);
64  }
65 
69  public function test_from_string(): void
70  {
71  $factory = new Factory();
72  $uuid = $factory->fromString(self::UUID4);
73 
74  $this->assertMatchesRegularExpression(self::VALID_UUID4, $uuid->toString());
75  $this->assertEquals(self::UUID4, $uuid->toString());
76  }
77 
81  public function test_from_illegal_string(): void
82  {
83  $this->expectException(InvalidUuidStringException::class);
84 
85  $factory = new Factory();
86  $factory->fromString(self::NO_UUID);
87  }
88 }
test_from_string()
test_init
Definition: UuidTest.php:69
const UUID4
Definition: UuidTest.php:32
test_from_illegal_string()
test_init
Definition: UuidTest.php:81
test_uuid4_string()
test_init
Definition: UuidTest.php:57
test_init()
Definition: UuidTest.php:38
const VALID_UUID4
Definition: UuidTest.php:30
const NO_UUID
Definition: UuidTest.php:33
test_uuid4()
test_init
Definition: UuidTest.php:46