diff options
-rw-r--r-- | php-hamcrest2.spec | 33 | ||||
-rw-r--r-- | upstream.patch | 397 |
2 files changed, 416 insertions, 14 deletions
diff --git a/php-hamcrest2.spec b/php-hamcrest2.spec index 82226ad..84e44e0 100644 --- a/php-hamcrest2.spec +++ b/php-hamcrest2.spec @@ -1,8 +1,8 @@ -# remirepo/fedora spec file for php-hamcrest +# remirepo/fedora spec file for php-hamcrest2 # -# Copyright (c) 2015-2020 Remi Collet -# License: CC-BY-SA -# http://creativecommons.org/licenses/by-sa/4.0/ +# SPDX-FileCopyrightText: Copyright 2015-2025 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt # # Please, preserve the changelog entries # @@ -16,24 +16,25 @@ Name: php-hamcrest2 Version: 2.0.1 -Release: 1%{?dist} +Release: 12%{?dist} Summary: PHP port of Hamcrest Matchers -Group: Development/Libraries -License: BSD +License: BSD-3-Clause URL: https://github.com/%{gh_owner}/%{gh_project} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{version}-%{gh_short}.tar.gz # Use generated autoloader instead of composer one Patch0: bootstrap-autoload.patch +# Upstream patch for testsuite +Patch1: upstream.patch BuildArch: noarch BuildRequires: php-fedora-autoloader-devel %if %{with tests} # From composer.json, require-dev: # "phpunit/php-file-iterator": "^1.4 || ^2.0", -# "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" -BuildRequires: phpunit7 +# "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0" +BuildRequires: phpunit9 # composer.json, require: # "php": "^5.3|^7.0|^8.0" BuildRequires: php(language) >= 5.3 @@ -71,8 +72,9 @@ Autoloader: %{_datadir}/php/%{ns_project}%{major}/autoload.php %prep %setup -q -n %{gh_project}-%{gh_commit} -%patch0 -p0 -b .rpm -find . -name \*.rpm -exec rm {} \; +%patch -P0 -p0 -b .rpm +%patch -P1 -p1 -b .up +find . -name \*.rpm -o -name \*.up -exec rm {} \; # Move to Library tree mv hamcrest/%{ns_project}.php hamcrest/%{ns_project}/%{ns_project}.php @@ -101,9 +103,9 @@ cp -pr hamcrest/%{ns_project} %{buildroot}%{_datadir}/php/%{ns_project}%{major} %if %{with tests} cd tests ret=0 -for cmd in php php72 php73 php74; do +for cmd in php php81 php82 php83 php84; do if which $cmd; then - $cmd %{_bindir}/phpunit7 --verbose || ret=1 + $cmd %{_bindir}/phpunit9 --verbose || ret=1 fi done exit $ret @@ -113,7 +115,6 @@ exit $ret %files -%{!?_licensedir:%global license %%doc} %license LICENSE.txt %doc CHANGES.txt README.md %doc composer.json @@ -121,6 +122,10 @@ exit $ret %changelog +* Wed Jan 22 2025 Remi Collet <remi@remirepo.net> - 2.0.1-12 +- switch to phpunit9 +- re-license spec file to CECILL-2.1 + * Thu Jul 9 2020 Remi Collet <remi@remirepo.net> - 2.0.1-1 - update to 2.0.1 - switch to phpunit7 diff --git a/upstream.patch b/upstream.patch new file mode 100644 index 0000000..f01e722 --- /dev/null +++ b/upstream.patch @@ -0,0 +1,397 @@ +From 696163addf28bb4e01455254e055a9a75e0ba6c4 Mon Sep 17 00:00:00 2001 +From: Fabien Villepinte <fabien.villepinte@gmail.com> +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 = <<<XML + <?xml version="1.0"?> +From 103d1443ec6c552ff1c15e2bddbb9ce7c96528be Mon Sep 17 00:00:00 2001 +From: Fabien Villepinte <fabien.villepinte@gmail.com> +Date: Fri, 3 May 2024 15:45:43 +0200 +Subject: [PATCH] Fix all PHPUnit's deprecations + +--- + .github/workflows/tests.yml | 14 +++++++++++++- + tests/Hamcrest/UtilTest.php | 23 +++++++++++++++-------- + 2 files changed, 28 insertions(+), 9 deletions(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index f23413216..68b483587 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -10,7 +10,19 @@ jobs: + runs-on: ubuntu-latest + strategy: + matrix: +- php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] ++ php: ++ - '5.3' ++ - '5.4' ++ - '5.5' ++ - '5.6' ++ - '7.0' ++ - '7.1' ++ - '7.2' ++ - '7.3' ++ - '7.4' ++ - '8.0' ++ - '8.1' ++ - '8.2' + + name: PHP ${{ matrix.php }} + +diff --git a/tests/Hamcrest/UtilTest.php b/tests/Hamcrest/UtilTest.php +index 7248978c7..1fec63eed 100644 +--- a/tests/Hamcrest/UtilTest.php ++++ b/tests/Hamcrest/UtilTest.php +@@ -28,21 +28,28 @@ public function testCheckAllAreMatchersAcceptsMatchers() + )); + } + +- /** +- * @expectedException InvalidArgumentException +- */ + public function testCheckAllAreMatchersFailsForPrimitive() + { +- \Hamcrest\Util::checkAllAreMatchers(array( +- new \Hamcrest\Text\MatchesPattern('/fo+/'), +- 'foo', +- )); ++ $exceptionThrown = false; ++ try { ++ \Hamcrest\Util::checkAllAreMatchers(array( ++ new \Hamcrest\Text\MatchesPattern('/fo+/'), ++ 'foo', ++ )); ++ } catch (\InvalidArgumentException $exception) { ++ $exceptionThrown = true; ++ } ++ ++ $this->assertTrue( ++ $exceptionThrown, ++ 'Failed asserting that exception of type "InvalidArgumentException" is thrown.' ++ ); + } + + private function callAndAssertCreateMatcherArray($items) + { + $matchers = \Hamcrest\Util::createMatcherArray($items); +- $this->assertInternalType('array', $matchers); ++ $this->assertTrue(is_array($matchers), sprintf('Type "array" expected, but got "%s" instead', gettype($matchers))); + $this->assertSameSize($items, $matchers); + foreach ($matchers as $matcher) { + $this->assertInstanceOf('\Hamcrest\Matcher', $matcher); +From e3b7bfcda4bc88f94e7f37f2a3a3380d4944735d Mon Sep 17 00:00:00 2001 +From: Fabien Villepinte <fabien.villepinte@gmail.com> +Date: Fri, 3 May 2024 15:50:55 +0200 +Subject: [PATCH] Allow installation of PHPUnit 9 in order to test with PHP 8.3 + +--- + .github/workflows/tests.yml | 1 + + composer.json | 4 ++-- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml +index 68b483587..de0cfff6f 100644 +--- a/.github/workflows/tests.yml ++++ b/.github/workflows/tests.yml +@@ -23,6 +23,7 @@ jobs: + - '8.0' + - '8.1' + - '8.2' ++ - '8.3' + + name: PHP ${{ matrix.php }} + +diff --git a/composer.json b/composer.json +index 180f341d8..c89b279e1 100644 +--- a/composer.json ++++ b/composer.json +@@ -19,8 +19,8 @@ + }, + + "require-dev": { +- "phpunit/php-file-iterator": "^1.4 || ^2.0", +- "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0" ++ "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0", ++ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + + "replace": { |