Failed Conditions
Pull Request — master (#2)
by Alexander
01:30
created

TAbstractTestCaseBody   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 35
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A onNotSuccessfulTestCompat() 0 2 1
A verifyMockeryExpectations() 0 15 3
1
<?php
2
/**
3
 * This file is part of the phpunit-mink library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/aik099/phpunit-mink
9
 */
10
11
namespace ConsoleHelpers\PHPUnitCompat;
12
13
14
use PHPUnit\Runner\Version;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Runner\Version was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
if ( \class_exists('\PHPUnit_Framework_IncompleteTestError') ) {
17
	\class_alias(
18
		'\PHPUnit_Framework_IncompleteTestError',
19
		'\ConsoleHelpers\PHPUnitCompat\Framework\IncompleteTestError'
20
	);
21
}
22
else {
23
	\class_alias(
24
		'\PHPUnit\Framework\IncompleteTestError',
25
		'\ConsoleHelpers\PHPUnitCompat\Framework\IncompleteTestError'
26
	);
27
}
28
29
if ( class_exists('\PHPUnit_Framework_SkippedTestError') ) {
30
	\class_alias('\PHPUnit_Framework_SkippedTestError', '\ConsoleHelpers\PHPUnitCompat\Framework\SkippedTestError');
31
}
32
else {
33
	\class_alias('\PHPUnit\Framework\SkippedTestError', '\ConsoleHelpers\PHPUnitCompat\Framework\SkippedTestError');
34
}
35
36
if ( class_exists('\PHPUnit_Framework_TestSuite_DataProvider') ) {
37
	\class_alias(
38
		'\PHPUnit_Framework_TestSuite_DataProvider',
39
		'\ConsoleHelpers\PHPUnitCompat\Framework\DataProviderTestSuite'
40
	);
41
}
42
else {
43
	\class_alias(
44
		'\PHPUnit\Framework\DataProviderTestSuite',
45
		'\ConsoleHelpers\PHPUnitCompat\Framework\DataProviderTestSuite'
46
	);
47
}
48
49
if ( class_exists('\PHPUnit_Framework_TestResult') ) {
50
	\class_alias('\PHPUnit_Framework_TestResult', '\ConsoleHelpers\PHPUnitCompat\Framework\TestResult');
51
}
52
else {
53
	\class_alias('\PHPUnit\Framework\TestResult', '\ConsoleHelpers\PHPUnitCompat\Framework\TestResult');
54
}
55
56
if ( class_exists('\PHPUnit_Framework_Test') ) {
57
	\class_alias('\PHPUnit_Framework_Test', '\ConsoleHelpers\PHPUnitCompat\Framework\Test');
58
}
59
else {
60
	\class_alias('\PHPUnit\Framework\Test', '\ConsoleHelpers\PHPUnitCompat\Framework\Test');
61
}
62
63
if ( class_exists('\PHP_CodeCoverage') ) {
64
	\class_alias('\PHP_CodeCoverage', '\aik099\SebastianBergmann\CodeCoverage\CodeCoverage');
65
}
66
else {
67
	\class_alias(
68
		'\SebastianBergmann\CodeCoverage\CodeCoverage',
69
		'\aik099\SebastianBergmann\CodeCoverage\CodeCoverage'
70
	);
71
}
72
73
if ( \interface_exists('\PHP_CodeCoverage_Driver') ) {
74
	\class_alias('\PHP_CodeCoverage_Driver', '\aik099\SebastianBergmann\CodeCoverage\Driver\Driver');
75
}
76
else {
77
	\class_alias(
78
		'\SebastianBergmann\CodeCoverage\Driver\Driver',
79
		'\aik099\SebastianBergmann\CodeCoverage\Driver\Driver'
80
	);
81
}
82
83
if ( class_exists('\PHP_CodeCoverage_Filter') ) {
84
	\class_alias('\PHP_CodeCoverage_Filter', '\aik099\SebastianBergmann\CodeCoverage\Filter');
85
}
86
else {
87
	\class_alias('\SebastianBergmann\CodeCoverage\Filter', '\aik099\SebastianBergmann\CodeCoverage\Filter');
88
}
89
90
if ( \class_exists('PHPUnit\Runner\Version') ) {
91
	$runner_version = Version::id();
92
}
93
else {
94
	$runner_version = \PHPUnit_Runner_Version::id();
0 ignored issues
show
Bug introduced by
The type PHPUnit_Runner_Version was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
95
}
96
97
98
trait TAbstractTestCaseBody
99
{
100
101
	/**
102
	 * This method is called when a test method did not execute successfully.
103
	 *
104
	 * @param \Exception|\Throwable $e Exception.
105
	 *
106
	 * @return void
107
	 */
108 1
	protected function onNotSuccessfulTestCompat($e)
1 ignored issue
show
Unused Code introduced by
The parameter $e is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

108
	protected function onNotSuccessfulTestCompat(/** @scrutinizer ignore-unused */ $e)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109
	{
110
111 1
	}
112
113
	/**
114
	 * @after
115
	 * @codeCoverageIgnore
116
	 * @internal
117
	 */
118
	protected function verifyMockeryExpectations()
119
	{
120
		if ( !\class_exists('Mockery') ) {
121
			return;
122
		}
123
124
		// Add Mockery expectations to assertion count.
125
		$container = \Mockery::getContainer();
1 ignored issue
show
Bug introduced by
The type Mockery was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
126
127
		if ( $container !== null ) {
128
			$this->addToAssertionCount($container->mockery_getExpectationCount());
0 ignored issues
show
Bug introduced by
It seems like addToAssertionCount() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

128
			$this->/** @scrutinizer ignore-call */ 
129
          addToAssertionCount($container->mockery_getExpectationCount());
Loading history...
129
		}
130
131
		// Verify Mockery expectations.
132
		\Mockery::close();
133
	}
134
135
}
136
137
if ( version_compare($runner_version, '6.0.0', '<') ) {
138
	require_once __DIR__ . '/AbstractTestCase5.php';
139
}
140
else {
141
	require_once __DIR__ . '/AbstractTestCase7.php';
142
}
143