Migrate CI to GitHub Actions and upgrade PHPUnit for PHP 8 compatibility#33
Merged
Conversation
Replace the CircleCI config with a GitHub Actions workflow that runs PHPUnit across a matrix of PHP versions (7.4, 8.0, 8.1, 8.2).
- Bump phpunit/phpunit constraint to ^9.5 - Replace removed PHPUnit_Framework_* class aliases with namespaced equivalents (PHPUnit\Framework\TestCase, Constraint\Constraint, etc.) - Replace setExpectedException() with expectException() - Replace assertContains() on strings with assertStringContainsString() - Add void return types to setUp/tearDown overrides - Declare explicit class properties to replace dynamic property creation, which is deprecated in PHP 8.2 and was being converted to errors by PHPUnit - Store MockObject method stubs in a $methods array instead of dynamic properties - Update UnmetExpectationException to extend RuntimeException since PHPUnit\Framework\ExpectationFailedException is now final
doctrine/instantiator 2.x requires PHP ^8.4, which breaks composer install on the PHP 7.4/8.0/8.1/8.2 matrix. Pinning to ^1.5 (supports PHP 7.1+) ensures the lock file is valid across all CI matrix versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
This migrates CI from CircleCI to GitHub Actions and upgrades PHPUnit from 5.x to 9.x, adding test coverage across PHP 7.4, 8.0, 8.1, and 8.2.
.circleci/config.ymland add.github/workflows/tests.ymlwith a PHP version matrix (7.4, 8.0, 8.1, 8.2)phpunit/phpunitfrom^5.2to^9.5doctrine/instantiatorto^1.5to prevent composer resolving a PHP 8.4-only version from the lock filePHPUnit_Framework_*class aliases with namespaced equivalents (PHPUnit\Framework\TestCase,PHPUnit\Framework\Constraint\Constraint, etc.)setExpectedException()withexpectException()in tests (removed in PHPUnit 6)assertContains()on strings withassertStringContainsString()(changed in PHPUnit 9)voidreturn types totearDown()overrides to match PHPUnit 9's signatureMockObject,MatchPattern,MatchArray,FalseyValue, andExpectationto replace dynamic property creation, which is deprecated in PHP 8.2 and treated as an error by PHPUnit's error handlerMockObjectto store method stubs in a private$methodsarray instead of as dynamic propertiesUnmetExpectationExceptionto extend\RuntimeExceptionsincePHPUnit\Framework\ExpectationFailedExceptionbecamefinalin PHPUnit 9Why are these changes being made?
CircleCI requires a separate account and integration, while GitHub Actions is built into the repository with no additional setup. The existing CI only tested PHP 7.4; expanding the matrix to include PHP 8.x makes sense given that recent PRs have been fixing PHP 8 compatibility issues.
PHPUnit 5.x does not support PHP 8 at all —
composer installfails outright on PHP 8.x with the old lock file. Upgrading to PHPUnit 9.x (which supports PHP 7.3 through 8.2) was the minimum version that covers the full matrix. The PHP 8.2 dynamic property deprecations were being promoted to test errors by PHPUnit's error handler, so those were fixed in source as well rather than just suppressed.Testing instructions
TC:
Manual testing: