public function testFilter() { // from js $evens = __u::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 = __u(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 = __u::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(__u::filter(array(1, 3, 5), $iterator), __u::select(array(1, 3, 5), $iterator), 'alias works'); // docs $this->assertEquals(array(2, 4), __u::filter(array(1, 2, 3, 4), function ($num) { return $num % 2 === 0; })); }