encode() 공개 메소드

Encode a Suite object into a XML document.
public encode ( SuiteCollection $suiteCollection ) : PhpBench\Dom\Document
$suiteCollection PhpBench\Model\SuiteCollection
리턴 PhpBench\Dom\Document
예제 #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);
 }
예제 #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());
 }
예제 #3
0
 private function encode(SuiteCollection $collection)
 {
     $xmlEncoder = new XmlEncoder();
     $dom = $xmlEncoder->encode($collection);
     return $dom;
 }