| @@ 142-185 (lines=44) @@ | ||
| 139 | return $merged; |
|
| 140 | } |
|
| 141 | ||
| 142 | protected function parseJunitFile($filename) |
|
| 143 | { |
|
| 144 | if (! is_readable($filename)) { |
|
| 145 | throw new \UnexpectedValueException(sprintf( |
|
| 146 | 'File %s is not readable', |
|
| 147 | basename($filename) |
|
| 148 | )); |
|
| 149 | } |
|
| 150 | $dom = new \DOMDocument(1.0, 'UTF-8'); |
|
| 151 | if (false === @$dom->load($filename)) { |
|
| 152 | throw new \UnexpectedValueException(sprintf( |
|
| 153 | 'File %s seems not to be a JUnit-File', |
|
| 154 | basename($filename) |
|
| 155 | )); |
|
| 156 | } |
|
| 157 | ||
| 158 | $xpath = new \DOMXPath($dom); |
|
| 159 | ||
| 160 | $result = []; |
|
| 161 | ||
| 162 | $items = $xpath->query('//testcase'); |
|
| 163 | foreach ($items as $item) { |
|
| 164 | ||
| 165 | if ($item->hasAttribute('class')) { |
|
| 166 | $class = $item->getAttribute('class'); |
|
| 167 | } else { |
|
| 168 | $class = explode('::', $item->parentNode->getAttribute('name'))[0]; |
|
| 169 | } |
|
| 170 | ||
| 171 | $type = 'success'; |
|
| 172 | ||
| 173 | foreach ($item->childNodes as $child) { |
|
| 174 | if ($child->nodeType != XML_ELEMENT_NODE) { |
|
| 175 | continue; |
|
| 176 | } |
|
| 177 | $type = $child->nodeName; |
|
| 178 | } |
|
| 179 | ||
| 180 | $result[$class . '::' . $item->getAttribute('name')] = $type; |
|
| 181 | ||
| 182 | } |
|
| 183 | ||
| 184 | return $result; |
|
| 185 | } |
|
| 186 | } |
|
| 187 | ||
| @@ 39-82 (lines=44) @@ | ||
| 36 | * |
|
| 37 | * @return array |
|
| 38 | */ |
|
| 39 | public function parseFile($filename) |
|
| 40 | { |
|
| 41 | if (! is_readable($filename)) { |
|
| 42 | throw new \UnexpectedValueException(sprintf( |
|
| 43 | 'File %s is not readable', |
|
| 44 | basename($filename) |
|
| 45 | )); |
|
| 46 | } |
|
| 47 | $dom = new \DOMDocument(1.0, 'UTF-8'); |
|
| 48 | if (false === @$dom->load($filename)) { |
|
| 49 | throw new \UnexpectedValueException(sprintf( |
|
| 50 | 'File %s seems not to be a JUnit-File', |
|
| 51 | basename($filename) |
|
| 52 | )); |
|
| 53 | } |
|
| 54 | ||
| 55 | $xpath = new \DOMXPath($dom); |
|
| 56 | ||
| 57 | $result = []; |
|
| 58 | ||
| 59 | $items = $xpath->query('//testcase'); |
|
| 60 | foreach ($items as $item) { |
|
| 61 | ||
| 62 | if ($item->hasAttribute('class')) { |
|
| 63 | $class = $item->getAttribute('class'); |
|
| 64 | } else { |
|
| 65 | $class = explode('::', $item->parentNode->getAttribute('name'))[0]; |
|
| 66 | } |
|
| 67 | ||
| 68 | $type = 'success'; |
|
| 69 | ||
| 70 | foreach ($item->childNodes as $child) { |
|
| 71 | if ($child->nodeType != XML_ELEMENT_NODE) { |
|
| 72 | continue; |
|
| 73 | } |
|
| 74 | $type = $child->nodeName; |
|
| 75 | } |
|
| 76 | ||
| 77 | $result[$class . '::' . $item->getAttribute('name')] = $type; |
|
| 78 | ||
| 79 | } |
|
| 80 | ||
| 81 | return $result; |
|
| 82 | } |
|
| 83 | } |
|