Completed
Branch master (474000)
by Tarmo
03:58
created

merge-phpunit-xml.php (2 issues)

Labels
Severity
1
#!/usr/bin/env php
2
<?php
3
declare(strict_types = 1);
4
require __DIR__ . '/vendor/autoload.php';
5
6
use SebastianBergmann\FinderFacade\FinderFacade;
1 ignored issue
show
The type SebastianBergmann\FinderFacade\FinderFacade was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use TheSeer\fDOM\fDOMDocument;
1 ignored issue
show
The type TheSeer\fDOM\fDOMDocument was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
$input  = new FinderFacade([$argv[1]], [], ['*.xml']);
10
$output = $argv[2];
11
12
$outXml = new fDOMDocument();
13
$outXml->formatOutput = true;
14
15
$outTestSuites = $outXml->createElement('testsuites');
16
$outXml->appendChild($outTestSuites);
17
18
$outTestSuite = $outXml->createElement('testsuite');
19
$outTestSuites->appendChild($outTestSuite);
20
21
$tests      = 0;
22
$assertions = 0;
23
$failures   = 0;
24
$errors     = 0;
25
$time       = 0;
26
27
try {
28
    foreach ($input->findFiles() as $file) {
29
        $inXml = new fDOMDocument();
30
        $inXml->load($file);
31
32
        foreach ($inXml->getElementsByTagName('testsuite') as $inElement) {
33
            $outElement = $outXml->importNode($inElement, true);
34
            $outTestSuite->appendChild($outElement);
35
            $tests      += $inElement->getAttribute('tests');
36
            $assertions += $inElement->getAttribute('assertions');
37
            $failures   += $inElement->getAttribute('failures');
38
            $errors     += $inElement->getAttribute('errors');
39
            $time       += $inElement->getAttribute('time');
40
        }
41
    }
42
43
    $outTestSuite->setAttribute('tests', $tests);
44
    $outTestSuite->setAttribute('assertions', $assertions);
45
    $outTestSuite->setAttribute('failures', $failures);
46
    $outTestSuite->setAttribute('errors', $errors);
47
    $outTestSuite->setAttribute('time', $time);
48
49
    $outXml->save($output);
50
} catch (\Exception $exception) {
51
    echo $exception->getMessage();
52
}
53