Passed
Push — developer ( be0222...346aa7 )
by Mariusz
41:58 queued 06:52
created

Times::addIncompleteTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
/**
3
 * Travis CI test script.
4
 *
5
 * @copyright YetiForce Sp. z o.o.
6
 * @license   YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
7
 * @author    Mariusz Krzaczkowski <[email protected]>
8
 * @author    Michał Lorencik <[email protected]>
9
 */
10
11
// @codeCoverageIgnoreStart
12
class Times implements PHPUnit\Framework\TestListener
13
{
14
	public function startTest(PHPUnit\Framework\Test $test)
15
	{
16
		//printf("Test %s started.\n", $test->getName());
17
		echo "\n";
18
	}
19
20
	public function endTest(PHPUnit\Framework\Test $test, $time)
21
	{
22
		$time = round($time, 2);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $time. This often makes code more readable.
Loading history...
23
		echo " Time: $time second(s)";
24
	}
25
26
	public function addError(PHPUnit\Framework\Test $test, Exception $e, $time)
27
	{
28
		echo 'Error in ' . $test->getName() . " !!!\n";
29
	}
30
31
	public function addWarning(PHPUnit\Framework\Test $test, PHPUnit\Framework\Warning $e, $time)
32
	{
33
		echo 'Warning in ' . $test->getName() . " !!!\n";
34
	}
35
36
	public function addFailure(PHPUnit\Framework\Test $test, PHPUnit\Framework\AssertionFailedError $e, $time)
37
	{
38
		echo 'Test ' . $test->getName() . " failed. $time\n";
39
		echo 'Exception Message: ' . $e->getMessage() . "\n";
40
		//echo "Exception Trace: " . $e->getTraceAsString() . "\n";
41
	}
42
43
	public function addIncompleteTest(PHPUnit\Framework\Test $test, Exception $e, $time)
44
	{
45
		$time = round($time, 2);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $time. This often makes code more readable.
Loading history...
Unused Code introduced by
$time is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
46
		printf("addIncompleteTest: Test '%s' is incomplete.\n", $test->getName());
47
	}
48
49
	public function addRiskyTest(PHPUnit\Framework\Test $test, Exception $e, $time)
50
	{
51
		printf("Test %s is deemed risky.\n", $test->getName());
52
		echo 'Exception Message: ' . $e->getMessage() . "\n";
53
		echo 'Exception Trace: ' . $e->getTraceAsString() . "\n";
54
	}
55
56
	public function addSkippedTest(PHPUnit\Framework\Test $test, Exception $e, $time)
57
	{
58
		$time = round($time, 2);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $time. This often makes code more readable.
Loading history...
59
		printf("Test '%s' has been skipped. ($time second(s))\n", $test->getName());
60
		echo 'Exception Message: ' . $e->getMessage() . "\n";
61
		echo 'Exception Trace: ' . $e->getTraceAsString() . "\n";
62
	}
63
64
	public function startTestSuite(PHPUnit\Framework\TestSuite $suite)
65
	{
66
		//printf("Started all tests: %s \n", $suite->getName());
67
	}
68
69
	public function endTestSuite(PHPUnit\Framework\TestSuite $suite)
70
	{
71
		//printf("Ended all tests: %s.\n", $suite->getName());
72
	}
73
}
74
75
// @codeCoverageIgnoreEnd
76