14 $ring =
new HashRing( [
's1' => 1,
's2' => 1,
's3' => 2,
's4' => 2,
's5' => 2,
's6' => 3 ] );
17 for ( $i = 0; $i < 20; $i++ ) {
18 $locations[
"hello$i"] = $ring->getLocation(
"hello$i" );
20 $expectedLocations = [
43 $this->assertEquals( $expectedLocations, $locations,
'Items placed at proper locations' );
46 for ( $i = 0; $i < 5; $i++ ) {
47 $locations[
"hello$i"] = $ring->getLocations(
"hello$i", 2 );
50 $expectedLocations = [
51 "hello0" => [
"s5",
"s6" ],
52 "hello1" => [
"s6",
"s4" ],
53 "hello2" => [
"s2",
"s1" ],
54 "hello3" => [
"s5",
"s6" ],
55 "hello4" => [
"s6",
"s4" ],
57 $this->assertEquals( $expectedLocations, $locations,
'Items placed at proper locations' );