19 $id = call_user_func( [
'UIDGenerator', $method ] );
20 $this->assertEquals(
true, ctype_digit( $id ),
"UID made of digit characters" );
21 $this->assertLessThanOrEqual( $digitlen, strlen( $id ),
22 "UID has the right number of digits" );
23 $this->assertLessThanOrEqual( $bits, strlen( Wikimedia\base_convert( $id, 10, 2 ) ),
24 "UID has the right number of bits" );
27 for ( $i = 0; $i < 300; $i++ ) {
28 $ids[] = call_user_func( [
'UIDGenerator', $method ] );
31 $lastId = array_shift( $ids );
33 $this->assertSame( array_unique( $ids ), $ids,
"All generated IDs are unique." );
35 foreach ( $ids
as $id ) {
38 $id_bin = Wikimedia\base_convert( $id, 10, 2, $bits );
39 $lastId_bin = Wikimedia\base_convert( $lastId, 10, 2, $bits );
41 $timestamp_bin = substr( $id_bin, 0, $tbits );
42 $last_timestamp_bin = substr( $lastId_bin, 0, $tbits );
44 $this->assertGreaterThanOrEqual(
47 "timestamp ($timestamp_bin) of current ID ($id_bin) >= timestamp ($last_timestamp_bin) " .
48 "of prior one ($lastId_bin)" );
50 $hostbits_bin = substr( $id_bin, -$hostbits );
51 $last_hostbits_bin = substr( $lastId_bin, -$hostbits );
57 "Host ID ($hostbits_bin) of current ID ($id_bin) is same as host ID ($last_hostbits_bin) " .
58 "of prior one ($lastId_bin)." );
71 [
'newTimestampedUID128', 39, 128, 46, 48 ],
72 [
'newTimestampedUID128', 39, 128, 46, 48 ],
73 [
'newTimestampedUID88', 27, 88, 46, 32 ],
82 for ( $i = 0; $i < 100; $i++ ) {
84 $this->assertEquals(
true,
85 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 ),
86 "UID $id has the right format" );
90 $this->assertEquals(
true,
91 preg_match(
'!^[0-9a-f]{12}1[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
92 "UID $id has the right format" );
95 $this->assertEquals(
true,
96 preg_match(
'!^[0-9a-f]{12}1[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
97 "UID $id has the right format" );
100 $this->assertEquals( array_unique( $ids ), $ids,
"All generated IDs are unique." );
108 for ( $i = 0; $i < 100; $i++ ) {
111 $this->assertEquals(
true,
112 preg_match(
'!^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$!', $id ),
113 "UID $id has the right format" );
116 $this->assertEquals( array_unique( $ids ), $ids,
'All generated IDs are unique.' );
123 for ( $i = 0; $i < 100; $i++ ) {
125 $this->assertEquals(
true,
126 preg_match(
'!^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
127 "UID $id has the right format" );
135 for ( $i = 0; $i < 100; $i++ ) {
137 $this->assertEquals(
true,
138 preg_match(
'!^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
139 "UID $id has the right format" );
150 $this->assertInternalType(
'float', $id1,
"ID returned as float" );
151 $this->assertInternalType(
'float', $id2,
"ID returned as float" );
152 $this->assertGreaterThan( 0, $id1,
"ID greater than 1" );
153 $this->assertGreaterThan( $id1, $id2,
"IDs increasing in value" );
162 foreach ( $ids
as $id ) {
163 $this->assertInternalType(
'float', $id,
"ID returned as float" );
164 $this->assertGreaterThan( 0, $id,
"ID greater than 1" );
166 $this->assertGreaterThan( $lastId, $id,
"IDs increasing in value" );
testRawUUIDv4QuickRand()
UIDGenerator::newRawUUIDv4.
testNewSequentialID()
UIDGenerator::newSequentialPerNodeID.
testRawUUIDv4()
UIDGenerator::newRawUUIDv4.
testUUIDv4()
UIDGenerator::newUUIDv4.
static newSequentialPerNodeIDs($bucket, $bits, $count, $flags=0)
Return IDs that are sequential only for this node and bucket.
testNewSequentialIDs()
UIDGenerator::newSequentialPerNodeIDs.
testUUIDv1()
UIDGenerator::newUUIDv1.
testTimestampedUID($method, $digitlen, $bits, $tbits, $hostbits)
Test that generated UIDs have the expected properties.
static newRawUUIDv4($flags=0)
Return an RFC4122 compliant v4 UUID.
static unitTestTearDown()
Cleanup resources when tearing down after a unit test.
static newUUIDv4($flags=0)
Return an RFC4122 compliant v4 UUID.
static newSequentialPerNodeID($bucket, $bits=48, $flags=0)
Return an ID that is sequential only for this node and bucket.
static provider_testTimestampedUID()
array( method, length, bits, hostbits ) NOTE: When adding a new method name here please update the co...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static newRawUUIDv1()
Return an RFC4122 compliant v1 UUID.
static newUUIDv1()
Return an RFC4122 compliant v1 UUID.