- return array(
- array( 'newTimestampedUID128', 39, 128, 46, 48 ),
- array( 'newTimestampedUID128', 39, 128, 46, 48 ),
- array( 'newTimestampedUID88', 27, 88, 46, 32 ),
- );
+ return [
+ [ 'newTimestampedUID128', 39, 128, 46, 48 ],
+ [ 'newTimestampedUID128', 39, 128, 46, 48 ],
+ [ 'newTimestampedUID88', 27, 88, 46, 32 ],
+ ];
+ }
+
+ /**
+ * @covers UIDGenerator::newUUIDv1
+ */
+ public function testUUIDv1() {
+ $ids = [];
+ for ( $i = 0; $i < 100; $i++ ) {
+ $id = UIDGenerator::newUUIDv1();
+ $this->assertEquals( true,
+ preg_match( '!^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$!', $id ),
+ "UID $id has the right format" );
+ $ids[] = $id;
+
+ $id = UIDGenerator::newRawUUIDv1();
+ $this->assertEquals( true,
+ preg_match( '!^[0-9a-f]{12}1[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
+ "UID $id has the right format" );
+
+ $id = UIDGenerator::newRawUUIDv1();
+ $this->assertEquals( true,
+ preg_match( '!^[0-9a-f]{12}1[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
+ "UID $id has the right format" );
+ }
+
+ $this->assertEquals( array_unique( $ids ), $ids, "All generated IDs are unique." );