MediaWiki  1.23.0
HashRingTest.php
Go to the documentation of this file.
1 <?php
2 
10  public function testHashRing() {
11  $ring = new HashRing( array( 's1' => 1, 's2' => 1, 's3' => 2, 's4' => 2, 's5' => 2, 's6' => 3 ) );
12 
13  $locations = array();
14  for ( $i = 0; $i < 20; $i++ ) {
15  $locations[ "hello$i"] = $ring->getLocation( "hello$i" );
16  }
17  $expectedLocations = array(
18  "hello0" => "s5",
19  "hello1" => "s6",
20  "hello2" => "s2",
21  "hello3" => "s5",
22  "hello4" => "s6",
23  "hello5" => "s4",
24  "hello6" => "s5",
25  "hello7" => "s4",
26  "hello8" => "s5",
27  "hello9" => "s5",
28  "hello10" => "s3",
29  "hello11" => "s6",
30  "hello12" => "s1",
31  "hello13" => "s3",
32  "hello14" => "s3",
33  "hello15" => "s5",
34  "hello16" => "s4",
35  "hello17" => "s6",
36  "hello18" => "s6",
37  "hello19" => "s3"
38  );
39 
40  $this->assertEquals( $expectedLocations, $locations, 'Items placed at proper locations' );
41 
42  $locations = array();
43  for ( $i = 0; $i < 5; $i++ ) {
44  $locations[ "hello$i"] = $ring->getLocations( "hello$i", 2 );
45  }
46 
47  $expectedLocations = array(
48  "hello0" => array( "s5", "s6" ),
49  "hello1" => array( "s6", "s4" ),
50  "hello2" => array( "s2", "s1" ),
51  "hello3" => array( "s5", "s6" ),
52  "hello4" => array( "s6", "s4" ),
53  );
54  $this->assertEquals( $expectedLocations, $locations, 'Items placed at proper locations' );
55  }
56 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
HashRingTest\testHashRing
testHashRing()
@covers HashRing
Definition: HashRingTest.php:10
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
HashRing
Convenience class for weighted consistent hash rings.
Definition: HashRing.php:29
HashRingTest
@group HashRing
Definition: HashRingTest.php:6