Skip to content

Commit

Permalink
Update UUIDTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Aug 31, 2024
1 parent 8a40366 commit f42b848
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/unit/utility/UUIDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ public function testV4(): void
$this->assertTrue(UUID::validate(UUID::v4()));
}

/**
*
*/
public function testV4Sequential(): void
{
$prev = UUID::v4Sequential();

for ($i = 0; $i < 100; $i++) {
usleep(10); // We need to sleep since they cannot be guaranteed to be 100% sequential due to the time presision

$uuid = UUID::v4Sequential();

$this->assertTrue(strcmp($prev, $uuid) <= 0);

$prev = $uuid;
}
}

/**
*
*/
Expand Down Expand Up @@ -161,22 +179,4 @@ public function testV5WithInvalidNamespace(): void

UUID::v5('nope', 'foobar');
}

/**
*
*/
public function testSequential(): void
{
$prev = UUID::v4Sequential();

for ($i = 0; $i < 100; $i++) {
usleep(10); // We need to sleep since they cannot be guaranteed to be 100% sequential due to the time presision

$uuid = UUID::v4Sequential();

$this->assertTrue(strcmp($prev, $uuid) <= 0);

$prev = $uuid;
}
}
}

0 comments on commit f42b848

Please sign in to comment.