示例#1
0
 public function factory($xmlContent)
 {
     $collection = new UnitCollection();
     $xml = simplexml_load_string($xmlContent);
     if (!$xml) {
         throw new \UnexpectedValueException('Invalid xml given');
     }
     $nodes = $xml->xpath('//testsuite/testsuite');
     if (!$nodes) {
         $nodes = $xml->xpath('//testsuites/testsuite');
     }
     foreach ($nodes as $n => $info) {
         $unit = new \Hal\MutaTesting\Test\Unit();
         $unit->setName((string) $info['name'])->setFile((string) $info['file'])->setNumOfAssertions((int) $info['assertions'])->setNumOfErrors((int) $info['errors'])->setNumOfFailures((int) $info['failures'])->setTime((string) $info['time']);
         $collection->push($unit);
     }
     return $collection;
 }