1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * Prints Clover XML output of the test
22
 *
23
 * @author  Daniel Kreckel <daniel@kreckel.koeln>
24
 * @package phing.tasks.ext.formatter
25
 */
26
class Crap4JPHPUnitResultFormatter7 extends PHPUnitResultFormatter7
27
{
28
    /**
29
     * @var PHPUnit\Framework\TestResult
30
     */
31
    private $result = null;
32
    /**
33
     * PHPUnit version
34
     *
35
     * @var string
36
     */
37
    private $version = null;
38

39
    /**
40
     * @param PHPUnitTask $parentTask
41
     */
42 0
    public function __construct(PHPUnitTask $parentTask)
43
    {
44 0
        parent::__construct($parentTask);
45 0
        $this->version = PHPUnit\Runner\Version::id();
46
    }
47

48
    /**
49
     * @return string
50
     */
51 0
    public function getExtension()
52
    {
53 0
        return '.xml';
54
    }
55

56
    /**
57
     * @return string
58
     */
59 0
    public function getPreferredOutfile()
60
    {
61 0
        return 'crap4j-coverage';
62
    }
63

64
    /**
65
     * @param PHPUnit\Framework\TestResult $result
66
     */
67 0
    public function processResult(PHPUnit\Framework\TestResult $result)
68
    {
69 0
        $this->result = $result;
70
    }
71

72 0
    public function endTestRun()
73
    {
74 0
        $coverage = $this->result->getCodeCoverage();
75 0
        if (!empty($coverage)) {
76 0
            $crapClass = '\SebastianBergmann\CodeCoverage\Report\Crap4j';
77 0
            $crap = new $crapClass();
78 0
            $contents = $crap->process($coverage);
79 0
            if ($this->out) {
80 0
                $this->out->write($contents);
81 0
                $this->out->close();
82
            }
83
        }
84 0
        parent::endTestRun();
85
    }
86
}

Read our documentation on viewing source code .

Loading