diff --git a/.travis.yml b/.travis.yml index 50f5f68..039a111 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: # see http://php.net/supported-versions.php - '7.3' # Until 6 Dec 2021 - '7.4' # Until 28 Nov 2022 + - '8.0' # Until 26 Nov 2023 env: global: @@ -11,9 +12,7 @@ env: - XDEBUG_MODE=coverage matrix: # see https://phpunit.de/supported-versions.html - - PHPUNIT_VERSION=8.0.* - PHPUNIT_VERSION=8.5.* - - PHPUNIT_VERSION=9.2.* - PHPUNIT_VERSION=9.5.* matrix: @@ -27,6 +26,14 @@ matrix: env: PHPUNIT_VERSION=7.5.* - php: '7.2' env: PHPUNIT_VERSION=8.5.* + - php: '7.3' + env: PHPUNIT_VERSION=8.0.* + - php: '7.4' + env: PHPUNIT_VERSION=8.5.* + - php: '8.0' + env: PHPUNIT_VERSION=8.5.* + - php: '8.0' + env: PHPUNIT_VERSION=8.4.* # We add some tests here for that we want to achieve or keep compatibility. # Some are made due to unstable SemVer of testing packages (guess which). diff --git a/lib/Compat/v8/Constraint/ArraySubset.php b/lib/Compat/v8/Constraint/ArraySubset.php index bdc11c8..3a20efa 100644 --- a/lib/Compat/v8/Constraint/ArraySubset.php +++ b/lib/Compat/v8/Constraint/ArraySubset.php @@ -35,7 +35,10 @@ class ArraySubset extends Constraint public function __construct(iterable $subset, bool $strict = false) { - parent::__construct(); + if (in_array('__construct', get_class_methods(Constraint::class))) { + // Seen in 8.4.* but vanished in 8.5.0 + parent::__construct(); + } $this->strict = $strict; $this->subset = $subset; @@ -96,6 +99,12 @@ public function evaluate($other, $description = '', $returnResult = false) */ public function toString(): string { + if (method_exists($this, 'exporter')) { + // For PHPUnit 8.5.* + return 'has the subset ' . $this->exporter()->export($this->subset); + } + + // For PHPUnit 8.4.* return 'has the subset ' . $this->exporter->export($this->subset); } diff --git a/opt/doc/TestCase/Constraint/ArraySubsetTest.php b/opt/doc/TestCase/Constraint/ArraySubsetTest.php new file mode 100644 index 0000000..51b8e3a --- /dev/null +++ b/opt/doc/TestCase/Constraint/ArraySubsetTest.php @@ -0,0 +1,50 @@ + 1], + ['c' => 3, 'a' => 1, 'b' => 2] + ); + } + + public function testFailsWhenArrayDoesNotHaveSubset() + { + $this->expectException(AssertionFailedError::class); + + self::assertArraySubset(['a' => 1], []); + } +}