21 $id = call_user_func( [ UIDGenerator::class, $method ] );
22 $this->assertEquals(
true, ctype_digit( $id ),
"UID made of digit characters" );
23 $this->assertLessThanOrEqual( $digitlen, strlen( $id ),
24 "UID has the right number of digits" );
25 $this->assertLessThanOrEqual( $bits, strlen( Wikimedia\base_convert( $id, 10, 2 ) ),
26 "UID has the right number of bits" );
29 for ( $i = 0; $i < 300; $i++ ) {
30 $ids[] = call_user_func( [ UIDGenerator::class, $method ] );
33 $lastId = array_shift( $ids );
35 $this->assertSame( array_unique( $ids ), $ids,
"All generated IDs are unique." );
37 foreach ( $ids as $id ) {
40 $id_bin = Wikimedia\base_convert( $id, 10, 2, $bits );
41 $lastId_bin = Wikimedia\base_convert( $lastId, 10, 2, $bits );
43 $timestamp_bin = substr( $id_bin, 0, $tbits );
44 $last_timestamp_bin = substr( $lastId_bin, 0, $tbits );
46 $this->assertGreaterThanOrEqual(
49 "timestamp ($timestamp_bin) of current ID ($id_bin) >= timestamp ($last_timestamp_bin) " .
50 "of prior one ($lastId_bin)" );
52 $hostbits_bin = substr( $id_bin, -$hostbits );
53 $last_hostbits_bin = substr( $lastId_bin, -$hostbits );
59 "Host ID ($hostbits_bin) of current ID ($id_bin) is same as host ID ($last_hostbits_bin) " .
60 "of prior one ($lastId_bin)." );