function _min($list, $iterator = NULL, $context = NULL)
{
    return Underscore::min($list, $iterator, $context);
}
Пример #2
0
 /**
  * @dataProvider peopleDataProvider
  * @tags collections
  */
 public function testMin($people, $type, $meta)
 {
     $age = function ($v) {
         return 2014 - _::get($v, 'born');
     };
     // it should return the first min element
     $this->variable(_::min($people, $age))->isEqualTo(_::get($people, 'nportman'));
     // the iterator function should be optional
     $this->typeTolerant([1, 4, 2, 3], 1, function ($in, $out) {
         $this->integer(_::min($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(_::min($people, $age, $context))->isEqualTo(_::get($people, 'nportman'));
 }