Skip to content

Commit b29854b

Browse files
gsherwoodjrfnl
andcommitted
Tests: the unit tests now require PHPUnit 8+
Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
1 parent 5380a4b commit b29854b

File tree

5 files changed

+4
-72
lines changed

5 files changed

+4
-72
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"ext-xmlwriter": "*"
3737
},
3838
"require-dev": {
39-
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
39+
"phpunit/phpunit": "^8.0 || ^9.3.4"
4040
},
4141
"bin": [
4242
"bin/phpcbf",

tests/AllTests.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,7 @@
1111

1212
require_once 'Core/AllTests.php';
1313
require_once 'Standards/AllSniffs.php';
14-
15-
// PHPUnit 7 made the TestSuite run() method incompatible with
16-
// older PHPUnit versions due to return type hints, so maintain
17-
// two different suite objects.
18-
$phpunit7 = false;
19-
if (class_exists('\PHPUnit\Runner\Version') === true) {
20-
$version = \PHPUnit\Runner\Version::id();
21-
if (version_compare($version, '7.0', '>=') === true) {
22-
$phpunit7 = true;
23-
}
24-
}
25-
26-
if ($phpunit7 === true) {
27-
include_once 'TestSuite7.php';
28-
} else {
29-
include_once 'TestSuite.php';
30-
}
14+
require_once 'TestSuite.php';
3115

3216
class PHP_CodeSniffer_AllTests
3317
{

tests/TestSuite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class TestSuite extends PHPUnit_TestSuite
1919
/**
2020
* Runs the tests and collects their result in a TestResult.
2121
*
22-
* @param \PHPUnit\Framework\TestResult $result A test result.
22+
* @param \PHPUnit\Framework\TestResult|null $result A test result.
2323
*
2424
* @return \PHPUnit\Framework\TestResult
2525
*/
26-
public function run(TestResult $result=null)
26+
public function run(?TestResult $result=null): TestResult
2727
{
2828
$result = parent::run($result);
2929
printPHPCodeSnifferTestOutput();

tests/TestSuite7.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/bootstrap.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,6 @@
4242

4343
$tokens = new \PHP_CodeSniffer\Util\Tokens();
4444

45-
// Compatibility for PHPUnit < 6 and PHPUnit 6+.
46-
if (class_exists('PHPUnit_Framework_TestSuite') === true && class_exists('PHPUnit\Framework\TestSuite') === false) {
47-
class_alias('PHPUnit_Framework_TestSuite', 'PHPUnit'.'\Framework\TestSuite');
48-
}
49-
50-
if (class_exists('PHPUnit_Framework_TestCase') === true && class_exists('PHPUnit\Framework\TestCase') === false) {
51-
class_alias('PHPUnit_Framework_TestCase', 'PHPUnit'.'\Framework\TestCase');
52-
}
53-
54-
if (class_exists('PHPUnit_TextUI_TestRunner') === true && class_exists('PHPUnit\TextUI\TestRunner') === false) {
55-
class_alias('PHPUnit_TextUI_TestRunner', 'PHPUnit'.'\TextUI\TestRunner');
56-
}
57-
58-
if (class_exists('PHPUnit_Framework_TestResult') === true && class_exists('PHPUnit\Framework\TestResult') === false) {
59-
class_alias('PHPUnit_Framework_TestResult', 'PHPUnit'.'\Framework\TestResult');
60-
}
61-
6245

6346
/**
6447
* A global util function to help print unit test fixing data.

0 commit comments

Comments
 (0)