Skip to content

Commit 5b565ef

Browse files
committed
Tests/PolyfilledTestCase: make compatible with PHPUnit Polyfills 3.x
As the available polyfill traits are different between the 1.x, 2.x and 3.x versions of the PHPUnit Polyfills, a different class definition is needed for PHPUnit Polyfills 3, which removes two traits (one used in this class) and introduces three new traits. This commit adds the version-conditional class declaration for PHPUnit Polyfills 3.0. Ref: * https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/3.0.0
1 parent 746a7a9 commit 5b565ef

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

Tests/PolyfilledTestCase.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PHPCSUtils\Tests\ExpectWithConsecutiveArgs;
1818
use PHPCSUtils\TestUtils\UtilityMethodTestCase;
1919
use Yoast\PHPUnitPolyfills\Autoload;
20+
use Yoast\PHPUnitPolyfills\Polyfills\AssertArrayWithListKeys;
2021
use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource;
2122
use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations;
2223
use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory;
@@ -27,15 +28,56 @@
2728
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
2829
use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType;
2930
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals;
31+
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectNotEquals;
3032
use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectProperty;
3133
use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
3234
use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
3335
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
3436
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
3537
use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
3638
use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
39+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectUserDeprecation;
3740

38-
if (\version_compare(Autoload::VERSION, '2.0.0', '>=')) {
41+
if (\version_compare(Autoload::VERSION, '3.0.0', '>=')) {
42+
/**
43+
* Abstract utility method base test case which includes all available polyfills (PHPUnit Polyfills 3.x compatible).
44+
*
45+
* This test case includes all polyfills from the PHPUnit Polyfill library to make them
46+
* available to the tests.
47+
*
48+
* Generally speaking, this testcase only needs to be used when the concrete test class will
49+
* use functionality which has changed in PHPUnit cross-version.
50+
* In all other cases, the `UtilityMethodTestCase` can be extended directly.
51+
*
52+
* {@internal The list of included polyfill traits should be reviewed after each new
53+
* release of the PHPUnit Polyfill library.}
54+
*
55+
* @since 1.1.0
56+
*/
57+
abstract class PolyfilledTestCase extends UtilityMethodTestCase
58+
{
59+
// PHPCSUtils native helpers.
60+
use AssertPropertySame;
61+
use ExpectWithConsecutiveArgs;
62+
63+
// PHPUnit Polyfills.
64+
use AssertArrayWithListKeys;
65+
use AssertClosedResource;
66+
use AssertEqualsSpecializations;
67+
use AssertFileEqualsSpecializations;
68+
use AssertIgnoringLineEndings;
69+
use AssertionRenames;
70+
use AssertIsList;
71+
use AssertIsType;
72+
use AssertObjectEquals;
73+
use AssertObjectNotEquals;
74+
use AssertObjectProperty;
75+
use AssertStringContains;
76+
use EqualToSpecializations;
77+
use ExpectExceptionMessageMatches;
78+
use ExpectUserDeprecation;
79+
}
80+
} elseif (\version_compare(Autoload::VERSION, '2.0.0', '>=')) {
3981
/**
4082
* Abstract utility method base test case which includes all available polyfills (PHPUnit Polyfills 2.x compaible).
4183
*

0 commit comments

Comments
 (0)