public function testFind() { // from js $this->assertEquals(2, __u::find(array(1, 2, 3), function ($num) { return $num * 2 === 4; }), 'found the first "2" and broke the loop'); // extra $iterator = function ($n) { return $n % 2 === 0; }; $this->assertEquals(2, __u::find(array(1, 2, 3, 4, 5, 6), $iterator)); $this->assertEquals(false, __u::find(array(1, 3, 5), $iterator)); $this->assertEquals(false, __u(array(1, 3, 5))->find($iterator), 'works with OO-style calls'); $this->assertEquals(__u::find(array(1, 3, 5), $iterator), __u::detect(array(1, 3, 5), $iterator), 'alias works'); // docs $this->assertEquals(2, __u::find(array(1, 2, 3, 4), function ($num) { return $num % 2 === 0; })); }