function _max($list, $iterator = NULL, $context = NULL) { return Underscore::max($list, $iterator, $context); }
/** * @dataProvider peopleDataProvider * @tags collections */ public function testMax($people, $type, $meta) { $age = function ($v) { return 2014 - _::get($v, 'born'); }; // it should return the first max element $this->variable(_::max($people, $age))->isEqualTo(_::get($people, 'jnicholson')); // the iterator function should be optional $this->typeTolerant([1, 4, 2, 3], 4, function ($in, $out) { $this->integer(_::max($in))->isEqualTo($out); }, [0, -1]); // it should be possible to specify a context for iteration function $age = function ($v) { return $this->year - _::get($v, 'born'); }; $context = (object) ['year' => 2014]; $this->variable(_::max($people, $age, $context))->isEqualTo(_::get($people, 'jnicholson')); }