Ejemplo n.º 1
0
 public function testAddAllWithSomeValues()
 {
     $arrayList = new Map();
     $arrayList->add(new Pair('key1', 'value1'))->add(new Pair('key2', 'value2'));
     $secoundArrayList = new Map();
     $secoundArrayList->add(new Pair('key3', 'value3'))->add(new Pair('key4', 'value4'));
     $arrayList->addAll($secoundArrayList);
     $this->assertEquals(['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4'], $arrayList->toArray());
 }
Ejemplo n.º 2
0
 public function testSort()
 {
     $array = ["d" => 8, "e" => -1, "b" => 0];
     $map = new Map($array);
     $this->assertEquals(["e" => -1, "b" => 0, "d" => 8], $map->sort()->toArray());
     $this->assertEquals($array, $map->toArray());
     //check that original colection is unaltered
     $this->assertEquals(["d" => 8, "b" => 0, "e" => -1], $map->sort(function ($a, $b) {
         return $a === $b ? 0 : $a > $b ? -1 : 1;
     })->toArray());
 }