function _partition($list, $iterator, $context = NULL) { return Underscore::partition($list, $iterator, $context); }
/** * @dataProvider peopleDataProvider * @tags collections */ public function testPartition($people, $type, $meta) { $isActor = function ($v) { return _::get($v, 'profession') == 'actor'; }; // it should separate items according to a distinction function $partitions = _::partition($people, $isActor); $this->integer(count($partitions[0]))->isEqualTo(4); $this->integer(count($partitions[1]))->isEqualTo(1); // it should be possible to pass a context for the distinction function $is = function ($v) { return _::get($v, 'profession') == $this->profession; }; $context = (object) ['profession' => 'actor']; $partitions = _::partition($people, $is, $context); $this->integer(count($partitions[0]))->isEqualTo(4); $this->integer(count($partitions[1]))->isEqualTo(1); }