11 $ring =
new HashRing(
array(
's1' => 1,
's2' => 1,
's3' => 2,
's4' => 2,
's5' => 2,
's6' => 3 ) );
14 for ( $i = 0; $i < 20; $i++ ) {
15 $locations[
"hello$i"] = $ring->getLocation(
"hello$i" );
17 $expectedLocations =
array(
40 $this->assertEquals( $expectedLocations, $locations,
'Items placed at proper locations' );
43 for ( $i = 0; $i < 5; $i++ ) {
44 $locations[
"hello$i"] = $ring->getLocations(
"hello$i", 2 );
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" ),
54 $this->assertEquals( $expectedLocations, $locations,
'Items placed at proper locations' );