comparison vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2 /*
3 * This file is part of the PHP_CodeCoverage package.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 /**
12 * @since Class available since Release 2.0.0
13 */
14 class PHP_CodeCoverage_Report_XML_Tests
15 {
16 private $contextNode;
17
18 private $codeMap = array(
19 0 => 'PASSED', // PHPUnit_Runner_BaseTestRunner::STATUS_PASSED
20 1 => 'SKIPPED', // PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED
21 2 => 'INCOMPLETE', // PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE
22 3 => 'FAILURE', // PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE
23 4 => 'ERROR', // PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
24 5 => 'RISKY' // PHPUnit_Runner_BaseTestRunner::STATUS_RISKY
25 );
26
27 public function __construct(DOMElement $context)
28 {
29 $this->contextNode = $context;
30 }
31
32 public function addTest($test, array $result)
33 {
34 $node = $this->contextNode->appendChild(
35 $this->contextNode->ownerDocument->createElementNS(
36 'http://schema.phpunit.de/coverage/1.0',
37 'test'
38 )
39 );
40 $node->setAttribute('name', $test);
41 $node->setAttribute('size', $result['size']);
42 $node->setAttribute('result', (int) $result['status']);
43 $node->setAttribute('status', $this->codeMap[(int) $result['status']]);
44 }
45 }