Replace PHPUnit with deminy/counit and fix php-cs-fixer CI failure - #130
Open
deminy wants to merge 2 commits into
Open
Replace PHPUnit with deminy/counit and fix php-cs-fixer CI failure#130deminy wants to merge 2 commits into
deminy wants to merge 2 commits into
Conversation
Switch the test runner from a hand-rolled coroutine wrapper around PHPUnit (tests/co-phpunit) to deminy/counit, which provides the same per-test Swoole coroutine execution as a maintained, versioned dependency with more correct reporting (accurate timing/assertion counts and late-failure handling via CounitExtension). - composer.json: require-dev deminy/counit ^0.3 (matches the existing phpunit/phpunit ~8.0/~9.0 usage) instead of phpunit/phpunit directly; "test" script now runs ./vendor/bin/counit. - phpunit.xml.dist: register Deminy\Counit\CounitExtension. - All test classes now extend Deminy\Counit\TestCase instead of PHPUnit\Framework\TestCase; the four classes overriding setUpBeforeClass()/tearDownAfterClass() call the parent methods, as required by TestCase. - Remove tests/co-phpunit, superseded by vendor/bin/counit. Verified: full suite (49 tests, incl. live-broker WebSocket tests) and static analysis (phpstan) both pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017FqMMVcHcgGongoKm1WrfX
composer.json pinned friendsofphp/php-cs-fixer to an open ^3.0 range with no committed composer.lock, so CI always resolved to whatever was newest on Packagist. That silently drifted the tool from 2021's ~3.x to the current 3.95.23, which broke cs-check two ways: - '@symfony'/'@PhpCsFixer' rule-set aliases absorbed many new fixers over that span, so the currently-formatted code now differs from what the latest version wants in 51 of 53 files. - 'increment_style' => [] was valid/no-op on old cs-fixer but is rejected by newer versions ("Configuration must be an array and may not be empty"), which is the crash CI actually hit. Fix: - .php-cs-fixer.php: set increment_style explicitly to ['style' => 'post'], matching the codebase's existing postfix (++/--) convention throughout, instead of the invalid empty array. - src/Tools/UnPackTool.php: fix the one spot using prefix increment (++$headBytes), inconsistent with the rest of the codebase, which the corrected rule now catches. - composer.json: pin friendsofphp/php-cs-fixer to the exact 3.7.0 (bisected under PHP 8.1 in Docker, matching the CI job's runtime, to confirm it's a version the current source needs zero changes against) instead of the open ^3.0 range, so this can't silently drift and break again on a future cs-fixer release. Verified with a from-scratch composer install (no cached vendor/ composer.lock) under PHP 8.1 in Docker: cs-check exits 0 with no files needing fixes, phpstan analyse reports no errors, and the counit unit suite passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017FqMMVcHcgGongoKm1WrfX
|
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.



Summary
Replaces the project's hand-rolled coroutine-aware PHPUnit runner (
tests/co-phpunit) withdeminy/counit, and fixes aphp-cs-fixerCI failure caused by an unpinned dependency version.Changes
Replace PHPUnit with deminy/counit for unit tests
composer.json:require-devnow pullsdeminy/counit: ^0.3(matches the existingphpunit/phpunit: ~8.0 || ~9.0usage) instead ofphpunit/phpunitdirectly; thetestscript now runs./vendor/bin/counit.phpunit.xml.dist: registersDeminy\Counit\CounitExtension, required for accurate timing/assertion counts and correct handling of failures/skips that happen after a coroutine yield.Deminy\Counit\TestCaseinstead ofPHPUnit\Framework\TestCase; the four classes overridingsetUpBeforeClass()/tearDownAfterClass()call the parent methods, asTestCaserequires.tests/co-phpunit, superseded by the package's ownvendor/bin/counitbinary.Fix php-cs-fixer CI failure
composer.jsonpinnedfriendsofphp/php-cs-fixerto an open^3.0range with no committedcomposer.lock, so CI always resolved to whatever was newest on Packagist. That silently drifted the tool from 2021's ~3.x to the current 3.95.x, which brokecs-checktwo ways: the@Symfony/@PhpCsFixerrule-set aliases absorbed many new fixers over that span (the current code differs from what the latest version wants in 51 of 53 files), and'increment_style' => []— valid/no-op on old cs-fixer — is rejected by newer versions ("Configuration must be an array and may not be empty")..php-cs-fixer.php: setsincrement_styleexplicitly to['style' => 'post'], matching the codebase's existing postfix (++/--) convention, instead of the invalid empty array.src/Tools/UnPackTool.php: fixes the one spot using prefix increment (++$headBytes), inconsistent with the rest of the codebase, which the corrected rule now catches.composer.json: pinsfriendsofphp/php-cs-fixerto the exact3.7.0(verified under PHP 8.1, matching the CI job's runtime, to be a version the current source needs zero changes against) instead of the open^3.0range, so this can't silently drift and break again on a future release.Testing
./vendor/bin/counit(49 tests, including the live-broker WebSocket tests): pass.composer analyse(phpstan): no errors.composer cs-check, verified with a from-scratchcomposer install(no cachedvendor/composer.lock) under PHP 8.1 in Docker, matching the CI job's runtime: exits 0, no files need fixing.