예제 #1
0
 public function testFilter()
 {
     $array = ["a" => 1, "b" => 2, "c" => 3];
     $map = new Map($array);
     $filtered = $map->filter(function ($_) {
         return $_ & 1;
     });
     $this->assertTrue($filtered instanceof Map);
     $this->assertEquals($array, $map->toArray());
     //check original Map is not altered
     $this->assertEquals(2, $filtered->count());
     $this->assertEquals(1, $filtered->get("a"));
     $this->assertEquals(3, $filtered->get("c"));
 }