hamcrest-php icon indicating copy to clipboard operation
hamcrest-php copied to clipboard

Update the test suite to run with a wider range of PHP versions

Open villfa opened this issue 1 year ago • 2 comments

This PR fixes all deprecations from PHPUnit with minimal changes. That way the tests can be run from PHP 5.3 up to PHP 8.3.

1) Hamcrest\UtilTest::testCheckAllAreMatchersFailsForPrimitive
The @expectedException, @expectedExceptionCode, @expectedExceptionMessage, and @expectedExceptionMessageRegExp annotations are deprecated. They will be removed in PHPUnit 9. Refactor your test to use expectException(), expectExceptionCode(), expectExceptionMessage(), or expectExceptionMessageMatches() instead.

2) Hamcrest\UtilTest::testCreateMatcherArrayLeavesMatchersUntouched
assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray() instead.

3) Hamcrest\UtilTest::testCreateMatcherArrayWrapsPrimitiveWithIsEqualMatcher
assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray() instead.

4) Hamcrest\UtilTest::testCreateMatcherArrayDoesntModifyOriginalArray
assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray() instead.

5) Hamcrest\UtilTest::testCreateMatcherArrayUnwrapsSingleArrayElement
assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray() instead.

villfa avatar May 03 '24 13:05 villfa

FYI: I've used https://github.com/Yoast/PHPUnit-Polyfills in my other projects and this way the test suite only uses the latest PHPUnit methods, which are polyfilled for older PHPUnit versions.

PR looks good to me.

aik099 avatar May 03 '24 14:05 aik099

FYI: I've used https://github.com/Yoast/PHPUnit-Polyfills in my other projects and this way the test suite only uses the latest PHPUnit methods, which are polyfilled for older PHPUnit versions.

True. On my own projects I use Symfony's PHPUnit bridge.

However, I chose not to add a new dependency because I believed the pull request would be better received that way, especially since it didn't require many changes.

villfa avatar May 03 '24 14:05 villfa

Hi @aik099, Do you think it's ok to merge this PR as is?

villfa avatar Jul 08 '24 08:07 villfa

Merging, thank you @villfa .

aik099 avatar Jul 08 '24 08:07 aik099