From 696163addf28bb4e01455254e055a9a75e0ba6c4 Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Thu, 14 Dec 2023 12:00:58 +0100 Subject: [PATCH] Allow installation of PHPUnit 8 in order to test with PHP 8.1 and 8.2 (#82) * Allow installation of PHPUnit 8 * Run the tests with PHP 8.1 and 8.2 --- .github/workflows/tests.yml | 9 ++------- .gitignore | 1 + composer.json | 2 +- tests/Hamcrest/Core/CombinableMatcherTest.php | 5 ++++- tests/Hamcrest/Core/IsInstanceOfTest.php | 5 ++++- tests/Hamcrest/Core/SetTest.php | 5 ++++- tests/Hamcrest/FeatureMatcherTest.php | 5 ++++- tests/Hamcrest/MatcherAssertTest.php | 5 ++++- tests/Hamcrest/StringDescriptionTest.php | 5 ++++- tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php | 5 ++++- tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php | 5 ++++- tests/Hamcrest/Text/StringContainsInOrderTest.php | 5 ++++- tests/Hamcrest/Text/StringContainsTest.php | 5 ++++- tests/Hamcrest/Text/StringEndsWithTest.php | 5 ++++- tests/Hamcrest/Text/StringStartsWithTest.php | 5 ++++- tests/Hamcrest/Xml/HasXPathTest.php | 5 ++++- 16 files changed, 56 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 06255a1b9..f23413216 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] name: PHP ${{ matrix.php }} @@ -26,13 +26,8 @@ jobs: tools: composer:v2 coverage: none - - name: Install PHP 7 dependencies + - name: Install PHP dependencies run: composer update --prefer-dist --no-interaction --no-progress - if: "matrix.php != '8.0'" - - - name: Install PHP 8 dependencies - run: composer update --prefer-dist --no-interaction --no-progress --ignore-platform-reqs - if: "matrix.php == '8.0'" - name: Execute tests run: vendor/bin/phpunit -c tests/phpunit.xml.dist diff --git a/.gitignore b/.gitignore index 987e2a253..7611d841f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ composer.lock +tests/.phpunit.result.cache vendor diff --git a/composer.json b/composer.json index 712ad9655..180f341d8 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require-dev": { "phpunit/php-file-iterator": "^1.4 || ^2.0", - "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0" }, "replace": { diff --git a/tests/Hamcrest/Core/CombinableMatcherTest.php b/tests/Hamcrest/Core/CombinableMatcherTest.php index 463c75437..ef9418674 100644 --- a/tests/Hamcrest/Core/CombinableMatcherTest.php +++ b/tests/Hamcrest/Core/CombinableMatcherTest.php @@ -7,7 +7,10 @@ class CombinableMatcherTest extends \Hamcrest\AbstractMatcherTest private $_either_3_or_4; private $_not_3_and_not_4; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_either_3_or_4 = \Hamcrest\Core\CombinableMatcher::either(equalTo(3))->orElse(equalTo(4)); $this->_not_3_and_not_4 = \Hamcrest\Core\CombinableMatcher::both(not(equalTo(3)))->andAlso(not(equalTo(4))); diff --git a/tests/Hamcrest/Core/IsInstanceOfTest.php b/tests/Hamcrest/Core/IsInstanceOfTest.php index f74cfdb52..b4fdd04fd 100644 --- a/tests/Hamcrest/Core/IsInstanceOfTest.php +++ b/tests/Hamcrest/Core/IsInstanceOfTest.php @@ -7,7 +7,10 @@ class IsInstanceOfTest extends \Hamcrest\AbstractMatcherTest private $_baseClassInstance; private $_subClassInstance; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_baseClassInstance = new \Hamcrest\Core\SampleBaseClass('good'); $this->_subClassInstance = new \Hamcrest\Core\SampleSubClass('good'); diff --git a/tests/Hamcrest/Core/SetTest.php b/tests/Hamcrest/Core/SetTest.php index aa5e4e7be..f00efa4f4 100644 --- a/tests/Hamcrest/Core/SetTest.php +++ b/tests/Hamcrest/Core/SetTest.php @@ -7,7 +7,10 @@ class SetTest extends \Hamcrest\AbstractMatcherTest public static $_classProperty; public $_instanceProperty; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { self::$_classProperty = null; unset($this->_instanceProperty); diff --git a/tests/Hamcrest/FeatureMatcherTest.php b/tests/Hamcrest/FeatureMatcherTest.php index 1b0230498..dfae872bf 100644 --- a/tests/Hamcrest/FeatureMatcherTest.php +++ b/tests/Hamcrest/FeatureMatcherTest.php @@ -34,7 +34,10 @@ class FeatureMatcherTest extends \Hamcrest\AbstractMatcherTest private $_resultMatcher; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_resultMatcher = $this->_resultMatcher(); } diff --git a/tests/Hamcrest/MatcherAssertTest.php b/tests/Hamcrest/MatcherAssertTest.php index dc12fba54..e34919869 100644 --- a/tests/Hamcrest/MatcherAssertTest.php +++ b/tests/Hamcrest/MatcherAssertTest.php @@ -6,7 +6,10 @@ class MatcherAssertTest extends TestCase { - protected function setUp() + /** + * @before + */ + protected function setUpTest() { \Hamcrest\MatcherAssert::resetCount(); } diff --git a/tests/Hamcrest/StringDescriptionTest.php b/tests/Hamcrest/StringDescriptionTest.php index ed716d13e..b42b9b469 100644 --- a/tests/Hamcrest/StringDescriptionTest.php +++ b/tests/Hamcrest/StringDescriptionTest.php @@ -23,7 +23,10 @@ class StringDescriptionTest extends TestCase private $_description; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_description = new \Hamcrest\StringDescription(); } diff --git a/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php b/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php index 27ad338b7..42444489f 100644 --- a/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php +++ b/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php @@ -6,7 +6,10 @@ class IsEqualIgnoringWhiteSpaceTest extends \Hamcrest\AbstractMatcherTest private $_matcher; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_matcher = \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace( "Hello World how\n are we? " diff --git a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php index 73023007b..8b4463a9e 100644 --- a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php +++ b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php @@ -8,7 +8,10 @@ class StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest private $_stringContains; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase( strtolower(self::EXCERPT) diff --git a/tests/Hamcrest/Text/StringContainsInOrderTest.php b/tests/Hamcrest/Text/StringContainsInOrderTest.php index 4c465b29d..adb8658f4 100644 --- a/tests/Hamcrest/Text/StringContainsInOrderTest.php +++ b/tests/Hamcrest/Text/StringContainsInOrderTest.php @@ -6,7 +6,10 @@ class StringContainsInOrderTest extends \Hamcrest\AbstractMatcherTest private $_m; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_m = \Hamcrest\Text\StringContainsInOrder::stringContainsInOrder(array('a', 'b', 'c')); } diff --git a/tests/Hamcrest/Text/StringContainsTest.php b/tests/Hamcrest/Text/StringContainsTest.php index bf4afa3c9..814c1ca1b 100644 --- a/tests/Hamcrest/Text/StringContainsTest.php +++ b/tests/Hamcrest/Text/StringContainsTest.php @@ -8,7 +8,10 @@ class StringContainsTest extends \Hamcrest\AbstractMatcherTest private $_stringContains; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_stringContains = \Hamcrest\Text\StringContains::containsString(self::EXCERPT); } diff --git a/tests/Hamcrest/Text/StringEndsWithTest.php b/tests/Hamcrest/Text/StringEndsWithTest.php index 9a30f9520..46177f464 100644 --- a/tests/Hamcrest/Text/StringEndsWithTest.php +++ b/tests/Hamcrest/Text/StringEndsWithTest.php @@ -8,7 +8,10 @@ class StringEndsWithTest extends \Hamcrest\AbstractMatcherTest private $_stringEndsWith; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_stringEndsWith = \Hamcrest\Text\StringEndsWith::endsWith(self::EXCERPT); } diff --git a/tests/Hamcrest/Text/StringStartsWithTest.php b/tests/Hamcrest/Text/StringStartsWithTest.php index 3be201f1a..f0eb14b7e 100644 --- a/tests/Hamcrest/Text/StringStartsWithTest.php +++ b/tests/Hamcrest/Text/StringStartsWithTest.php @@ -8,7 +8,10 @@ class StringStartsWithTest extends \Hamcrest\AbstractMatcherTest private $_stringStartsWith; - protected function setUp() + /** + * @before + */ + protected function setUpTest() { $this->_stringStartsWith = \Hamcrest\Text\StringStartsWith::startsWith(self::EXCERPT); } diff --git a/tests/Hamcrest/Xml/HasXPathTest.php b/tests/Hamcrest/Xml/HasXPathTest.php index 677488716..3db5e46e0 100644 --- a/tests/Hamcrest/Xml/HasXPathTest.php +++ b/tests/Hamcrest/Xml/HasXPathTest.php @@ -7,7 +7,10 @@ class HasXPathTest extends \Hamcrest\AbstractMatcherTest protected static $doc; protected static $html; - public static function setUpBeforeClass() + /** + * @beforeClass + */ + public static function setUpBeforeClassTest() { self::$xml = <<