public function testFilter() { // from js $evens = __::filter(array(1, 2, 3, 4, 5, 6), function ($num) { return $num % 2 === 0; }); $this->assertEquals(array(2, 4, 6), $evens, 'selected each even number'); // extra $odds = __(array(1, 2, 3, 4, 5, 6))->filter(function ($num) { return $num % 2 !== 0; }); $this->assertEquals(array(1, 3, 5), $odds, 'works with OO-style calls'); $evens = __::filter(array(1, 2, 3, 4, 5, 6), function ($num) { return $num % 2 === 0; }); $this->assertEquals(array(2, 4, 6), $evens, 'aliased as filter'); $iterator = function ($num) { return $num % 2 !== 0; }; $this->assertEquals(__::filter(array(1, 3, 5), $iterator), __::select(array(1, 3, 5), $iterator), 'alias works'); // docs $this->assertEquals(array(2, 4), __::filter(array(1, 2, 3, 4), function ($num) { return $num % 2 === 0; })); }