public function testPartition() { $this->_coll[] = true; $this->_coll[] = false; $partition = $this->_coll->partition(function ($k, $e) { return $e == true; }); $this->assertEquals($partition[0][0], true); $this->assertEquals($partition[1][0], false); }
/** * {@inheritDoc} */ public function partition(Closure $p) { $array = $this->toArray(); $this->collection->clear(); foreach ($array as $key => $element) { $this->collection->set($key, $element); } $partitions = $this->collection->partition($p); return [new static($partitions[0]), new static($partitions[1])]; }
/** * {@inheritdoc} */ public function partition(Closure $p) { $this->initialize(); return $this->coll->partition($p); }
/** * {@inheritdoc} */ public function partition(\Closure $p) { return $this->inner->partition($p); }
/** * @dataProvider provideCollection */ public function testPartitionCreatesCorrectInstance(Collection $coll, array $elements) { list($match, $noMatch) = $coll->partition(function () { return true; }); $this->assertInstanceOf(get_class($coll), $match); $this->assertInstanceOf(get_class($coll), $noMatch); $this->assertCount(0, $noMatch); $this->assertCount(count($elements), $match); }