- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Complete PHPUnit 9+ Migration and Dispatcher Simplification #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    Conversation
  
    
      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
    
  
  
    
    - Removed manual CAKE_CORE_INCLUDE_PATH detection from dispatcher files - Removed include_path manipulation logic (Composer autoload handles this) - Removed legacy app/Vendor/cakephp/cakephp path detection - Added clear error messages when Composer vendors directory or autoload.php is missing - Added clear error message when CakePHP core is not installed via Composer - Retained PHP built-in server support for development convenience - Updated both app/ and skel/ template files for consistency Breaking Change: Non-Composer installation is no longer supported. Projects must use Composer for dependency management. Migration: Copy updated dispatcher files from vendors/friendsofcake2/cakephp/lib/Cake/Console/Templates/skel/ to your application (webroot/index.php, webroot/test.php, Console/cake). Updated documentation: - Added CHANGELOG entry for dispatcher improvements - Added README installation instructions for copying dispatcher files - Added Composer-only requirement to Breaking Changes section
- Simplify PHPUnit framework detection using modern TestCase class - Remove unused CakeTestRunner class and associated run() method - Update type hints from PHPUnit_Framework_* to PHPUnit\Framework\* - Add use statements for PHPUnit classes to improve code clarity - Add vendor/ paths to App::path() for better Composer compatibility - Fix trailing commas in trigger_error calls for consistency - Remove index.php from phpcs.xml scope
| Codecov Report❌ Patch coverage is  📢 Thoughts on this report? Let us know! | 
Add allow-plugins configuration for dealerdirect/phpcodesniffer-composer-installer to comply with Composer 2.2+ plugin security requirements.
- Refactor CakeTestLoader to implement TestSuiteLoader interface with composition - Update ProjectTaskTest assertions to match new VENDORS constant - Fix FolderTest to use WWW_ROOT instead of APP for index.php path - Update load() method signature to match PHPUnit interface requirements
… checks TestSuite improvements: - Fix critical infinite recursion bug in CakeTestLoader::reload() - Change CakeBaseReporter from extending PHPUnit_TextUI_ResultPrinter to implementing ResultPrinter interface - Add type declarations throughout TestSuite classes for PHP 8.0+ compatibility - Add run() method to CakeTestSuiteCommand with proper test file resolution - Update HtmlCoverageReportTest to use CakeHtmlReporter instead of CakeBaseReporter - Add missing interface methods (write, addWarning, addRiskyTest) to CakeBaseReporter Remove legacy PHP version checks: - Remove PHP 5.3/5.4 compatibility code from ErrorHandler, Debugger, CakeSocket - Remove PHP 5.4 fallback in CakeNumber::_numberFormat() - Remove PHP version checks from CakeTimeTest - Remove PHPUnit version check from test files Code style improvements: - Fix indentation in basics.php (standardize whitespace) - Change include to require_once in bootstrap files for consistency - Remove get_magic_quotes_gpc exclusion from phpcs.xml (function removed in PHP 7.4) - Add CakeHtmlReporter to unused variable exclusion list Other changes: - Update test assertions to match new dispatcher structure - Simplify home.ctp formatting
- Change GitHub organization URLs from cakephp to friendsofcake2 in home.ctp - Update changelog, issues, wiki, and plugin repository links - Remove upstream CONTRIBUTING.md as this is a fork with different contribution guidelines
JsonView: - Only apply JSON_PRETTY_PRINT when debug mode is enabled - Improves performance in production environments App::load(): - Add class_exists check at the beginning to prevent unnecessary loading - Improves performance when class is already loaded Test bootstrap: - Replace direct ShellDispatcher require with App::load() - More consistent with CakePHP's autoloading patterns
TestShellTest.php: - Remove PHPUnit version check (test now works with PHPUnit 9+) - Fix testAvailableWithEmptyList to expect 2 out() calls (message + help) - Improve testAvailableCoreCategory to use callback for output verification - Verify actual output content using array capture instead of withConsecutive header.php: - Add missing PHPUnit\Runner\Version import
CHANGELOG.md: - Add comprehensive PHPUnit 9+ migration section - Document removal of legacy PHP version checks - Add JSON output optimization improvements - Document App::load() enhancement - Add coding standards and GitHub URLs update sections - Reorganize sections for better readability README.md: - Add PR #14 link to Composer-Only Installation breaking change - Document removal of app/Console/cake.bat and cake.php files - Add migration step to remove old dispatcher files
  
    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
This PR completes the migration to PHPUnit 9+ architecture and simplifies the dispatcher infrastructure by removing legacy compatibility code. The test suite now fully utilizes modern PHPUnit interfaces and all tests pass on PHPUnit 9.6+ across PHP 8.0-8.5.
Changes
PHPUnit 9+ Architecture
Test Suite Infrastructure:
CakeTestLoaderto implementTestSuiteLoaderinterface with composition patternCakeTestLoader::reload()method that would cause stack overflowCakeBaseReporterfrom extendingPHPUnit_TextUI_ResultPrinterto implementingResultPrinterinterfacewrite(),addWarning(),addRiskyTest()to maintain PHPUnit 9+ compatibilityCakeTestRunnerclass - functionality moved toCakeTestSuiteCommand::run()PHPUnit_Framework_*toPHPUnit\Framework\*namespaceTest Fixes:
TestShellTestassertions using callback-based output verification instead of deprecatedwithConsecutive()HtmlCoverageReportTestto useCakeHtmlReporterinstead of abstractCakeBaseReporterProjectTaskTestassertions to match new dispatcher structure (VENDORS constant)Dispatcher Simplification (Breaking Change)
Removed Files:
app/Console/cake.batandapp/Console/cake.php(Windows-specific wrappers no longer needed)lib/Cake/Console/cake.batandlib/Cake/Console/cake.phpapp/index.php, rootindex.php, and.htaccessfilesvendors/emptyplaceholder fileSimplified Logic:
CAKE_CORE_INCLUDE_PATHdetection from dispatcher filesinclude_pathmanipulation logic (Composer autoload handles this)app/Vendor/cakephp/cakephppath detectionincludetorequire_oncein bootstrap files for consistencyLegacy Code Removal
PHP Version Checks:
ErrorHandler,Debugger,CakeSocketCakeNumber::_numberFormat()CakeSocketModernization:
strpos()tostr_ends_with()inCakeTestLoaderbasics.phpto standardize whitespaceget_magic_quotes_gpcexclusion from phpcs.xml (function removed in PHP 7.4)Performance Improvements
JSON Output Optimization:
JsonViewnow only appliesJSON_PRETTY_PRINTwhen debug mode is enabledAutoloading Enhancement:
App::load()to prevent unnecessary file loadingShellDispatcherrequire withApp::load()in test bootstrapclass_exists()guard to prevent double definition errorsCode Quality
Coding Standards:
trigger_error()calls for consistencyCakeHtmlReporterto unused variable exclusion list in phpcs.xmlPHPUnit\Runner\Versionimport to test template headerDocumentation:
cakephptofriendsofcake2in home.ctp templatesCONTRIBUTING.md(fork has different contribution guidelines)Why These Changes?
PHPUnit 9+ Compatibility
PHPUnit 9 introduced significant architectural changes, including the removal of base classes like
PHPUnit_TextUI_ResultPrinterin favor of interfaces. Our test infrastructure was still using the old architecture, which prevented proper operation with modern PHPUnit versions.Simplified Maintenance
Removing legacy PHP version checks and compatibility code reduces maintenance burden and makes the codebase easier to understand. Since this fork requires PHP 8.0+, there's no need to maintain code paths for PHP 5.x.
Improved Performance
The
App::load()enhancement and JSON output optimization provide measurable performance improvements in production scenarios without affecting functionality.Better Developer Experience
Clearer error messages when Composer dependencies are missing help developers quickly identify and fix configuration issues.
Breaking Changes
Projects must use Composer for dependency management. Manual installation paths and
include_pathmanipulation have been removed from dispatcher files.Migration Required:
Impact: Applications already using Composer (recommended setup) require only file updates. Applications using manual installation will need to migrate to Composer.
Files Changed