encode() public method

Encode a Suite object into a XML document.
public encode ( SuiteCollection $suiteCollection ) : PhpBench\Dom\Document
$suiteCollection PhpBench\Model\SuiteCollection
return PhpBench\Dom\Document
Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function archive(OutputInterface $output)
 {
     $driver = $this->storageRegistry->getService();
     if (!$this->filesystem->exists($this->archivePath)) {
         $this->filesystem->mkdir($this->archivePath);
     }
     $runIds = [];
     foreach ($driver->history() as $entry) {
         $runIds[] = $entry->getRunId();
     }
     $output->writeln(sprintf('Archiving "%s" suites', count($runIds)));
     foreach ($runIds as $index => $runId) {
         $filename = $runId . '.xml';
         $path = sprintf('%s/%s', $this->archivePath, $filename);
         if ($this->filesystem->exists($path)) {
             $this->writeProgress($output, $index, count($runIds), 'S');
             continue;
         }
         $this->writeProgress($output, $index, count($runIds), '.');
         $collection = $driver->fetch($runId);
         $document = $this->xmlEncoder->encode($collection);
         $document->save($path);
     }
     $output->writeln(PHP_EOL);
 }
Beispiel #2
0
 /**
  * It should encode the suite to an XML document.
  *
  * @dataProvider provideEncode
  */
 public function testEncode(array $params, $expected)
 {
     $expected = str_replace('PHPBENCH_VERSION', PhpBench::VERSION, $expected);
     $collection = $this->getSuiteCollection($params);
     $xmlEncoder = new XmlEncoder();
     $dom = $xmlEncoder->encode($collection);
     $this->assertInstanceOf('PhpBench\\Dom\\Document', $dom);
     $this->assertEquals($expected, $dom->dump());
 }
Beispiel #3
0
 private function encode(SuiteCollection $collection)
 {
     $xmlEncoder = new XmlEncoder();
     $dom = $xmlEncoder->encode($collection);
     return $dom;
 }