mergeCollection() public method

Merge another collection into this one.
public mergeCollection ( SuiteCollection $collection )
$collection SuiteCollection
Ejemplo n.º 1
0
 public function suiteCollectionFromInput(InputInterface $input)
 {
     $files = $input->getOption('file');
     $queries = $input->getOption('query');
     $uuids = $input->getOption('uuid');
     if (!$files && !$queries && !$uuids) {
         throw new \InvalidArgumentException('You must specify at least one of `--query` and/or `--uuid`');
     }
     $collection = new SuiteCollection();
     if ($files) {
         $collection->mergeCollection($this->xmlDecoder->decodeFiles($files));
     }
     if ($queries) {
         foreach ($queries as $query) {
             $constraint = $this->parser->parse($query);
             $collection->mergeCollection($this->storage->getService()->query($constraint));
         }
     }
     if ($uuids) {
         foreach ($uuids as $uuid) {
             $uuid = $this->uuidResolver->resolve($uuid);
             $collection->mergeCollection($this->storage->getService()->fetch($uuid));
         }
     }
     return $collection;
 }
Ejemplo n.º 2
0
 /**
  * It should merge another colleciton into itself.
  */
 public function testMergeCollection()
 {
     $collection = new SuiteCollection([$this->suite1->reveal()]);
     $newCollection = new SuiteCollection([$this->suite2->reveal(), $this->suite3->reveal()]);
     $collection->mergeCollection($newCollection);
     $this->assertEquals([$this->suite1->reveal(), $this->suite2->reveal(), $this->suite3->reveal()], $collection->getSuites());
 }