~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @category   PHP
 
13
 * @package    CodeCoverage
 
14
 * @author     Arne Blankerts <arne@blankerts.de>
 
15
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 
16
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 
17
 * @link       http://github.com/sebastianbergmann/php-code-coverage
 
18
 * @since      Class available since Release 2.0.0
 
19
 */
 
20
class PHP_CodeCoverage_Report_XML_Tests
 
21
{
 
22
    private $contextNode;
 
23
 
 
24
    private $codeMap = array(
 
25
        0 => 'PASSED',     // PHPUnit_Runner_BaseTestRunner::STATUS_PASSED
 
26
        1 => 'SKIPPED',    // PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED
 
27
        2 => 'INCOMPLETE', // PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE
 
28
        3 => 'FAILURE',    // PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE
 
29
        4 => 'ERROR',      // PHPUnit_Runner_BaseTestRunner::STATUS_ERROR
 
30
        5 => 'RISKY'       // PHPUnit_Runner_BaseTestRunner::STATUS_RISKY
 
31
    );
 
32
 
 
33
    public function __construct(DOMElement $context)
 
34
    {
 
35
        $this->contextNode = $context;
 
36
    }
 
37
 
 
38
    public function addTest($test, $result)
 
39
    {
 
40
        $node = $this->contextNode->appendChild(
 
41
            $this->contextNode->ownerDocument->createElementNS(
 
42
                'http://schema.phpunit.de/coverage/1.0', 'test'
 
43
            )
 
44
        );
 
45
        $node->setAttribute('name', $test);
 
46
        $node->setAttribute('result', (int) $result);
 
47
        $node->setAttribute('status', $this->codeMap[(int) $result]);
 
48
 
 
49
    }
 
50
}