Exemplo n.º 1
0
 public function testMap()
 {
     $array = ["a" => 1, "b" => 2, "c" => 3];
     $map = new Map($array);
     $highLevelFunction = function ($pow) {
         return function ($item) use($pow) {
             return pow($item, $pow);
         };
     };
     $filtered = $map->map($highLevelFunction(2));
     $this->assertTrue($filtered instanceof Map);
     $this->assertEquals($array, $map->toArray());
     $this->assertEquals(3, $filtered->count());
     $this->assertEquals(1, $filtered->get("a"));
     $this->assertEquals(4, $filtered->get("b"));
     $this->assertEquals(9, $filtered->get("c"));
 }