11 $ring =
new HashRing( [
'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 = [
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 = [
48 "hello0" => [
"s5",
"s6" ],
49 "hello1" => [
"s6",
"s4" ],
50 "hello2" => [
"s2",
"s1" ],
51 "hello3" => [
"s5",
"s6" ],
52 "hello4" => [
"s6",
"s4" ],
54 $this->assertEquals( $expectedLocations, $locations,
'Items placed at proper locations' );