Repository navigation
Expand file tree
/
Copy pathJUnit.php
More file actions
41 lines (32 loc) · 1.33 KB
/
Copy pathJUnit.php
File metadata and controls
41 lines (32 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Codeception\PHPUnit\Log;
class JUnit extends \PHPUnit_Util_Log_JUnit
{
public function startTest(\PHPUnit_Framework_Test $test)
{
if (!($test instanceof \Codeception\TestCase\Cept)) return parent::startTest($test);
$this->currentTestCase = $this->document->createElement('testcase');
if ($test instanceof \Codeception\TestCase\Cept) {
$this->currentTestCase->setAttribute('file', $test->getFileName());
return;
}
if ($test instanceof \Codeception\TestCase) {
$class = new \ReflectionClass($test->getTestClass());
$methodName = $test->getTestMethod();
if ($class->hasMethod($methodName)) {
$method = $class->getMethod($methodName);
$this->currentTestCase->setAttribute('class', $class->getName());
$this->currentTestCase->setAttribute('file', $class->getFileName());
$this->currentTestCase->setAttribute('line', $method->getStartLine());
}
}
}
public function endTest(\PHPUnit_Framework_Test $test, $time) {
if ($test instanceof \Codeception\TestCase\Cept) {
$this->currentTestCase->setAttribute(
'name', $test->toString()
);
}
return parent::endTest($test, $time);
}
}