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; }
/** * 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()); }