ILIAS  release_7 Revision v7.30-3-g800a261c036
UuidTest.php
Go to the documentation of this file.
1 <?php
2 require_once("libs/composer/vendor/autoload.php");
3 
8 
9 class UuidTest extends TestCase
10 {
11  const VALID_UUID4 = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/';
12 
13  const UUID4 = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';
14  const NO_UUID = 'lorem ipsum dolor';
15 
19  public function test_init()
20  {
21  return new Factory();
22  }
23 
27  public function test_uuid4()
28  {
29  $factory = new Factory();
30  $uuid = $factory->uuid4();
31 
32  $this->assertEquals(1, preg_match(self::VALID_UUID4, $uuid->toString()));
33  }
34 
38  public function test_uuid4_string()
39  {
40  $factory = new Factory();
41  $uuid = $factory->uuid4AsString();
42 
43  $this->assertTrue(is_string($uuid));
44  $this->assertEquals(1, preg_match(self::VALID_UUID4, $uuid));
45  }
46 
50  public function test_from_string()
51  {
52  $factory = new Factory();
53  $uuid = $factory->fromString(self::UUID4);
54 
55  $this->assertEquals(1, preg_match(self::VALID_UUID4, $uuid->toString()));
56  $this->assertEquals(self::UUID4, $uuid->toString());
57  }
58 
62  public function test_from_illegal_string()
63  {
64  $this->expectException(InvalidUuidStringException::class);
65 
66  $factory = new Factory();
67  $factory->fromString(self::NO_UUID);
68  }
69 }
test_from_string()
test_init
Definition: UuidTest.php:50
const UUID4
Definition: UuidTest.php:13
test_from_illegal_string()
test_init
Definition: UuidTest.php:62
test_uuid4_string()
test_init
Definition: UuidTest.php:38
test_init()
Definition: UuidTest.php:19
const VALID_UUID4
Definition: UuidTest.php:11
$factory
Definition: metadata.php:58
const NO_UUID
Definition: UuidTest.php:14
test_uuid4()
test_init
Definition: UuidTest.php:27