Summary
The generated wordpress.phpunit Playground harness crashes during load_tests with PHPUnit 10+ because it directly constructs PHPUnit\Framework\TestSuite, whose constructor is private in those versions.
Downstream report: Extra-Chill/homeboy-extensions#2258.
Reproduction
A Homeboy WordPress release gate using WP Codebox 0.12.14 installed WordPress and dependencies and discovered 46 *Test.php files, then failed before any component test ran:
STAGE_FATAL:load_tests:Uncaught Error: Call to private PHPUnit\Framework\TestSuite::__construct() from global scope in /internal/eval.php:1096
The defect remains on current main at both generated harness sites:
packages/runtime-playground/src/phpunit-command-handlers.ts:1273 (phpunitRunCode)
packages/runtime-playground/src/phpunit-command-handlers.ts:1592 (corePhpunitRunCode)
Both emit new PHPUnit\Framework\TestSuite(...).
Compatibility approach
Use the public factory when available, preserving PHPUnit 9 compatibility:
$suite = method_exists(PHPUnit\Framework\TestSuite::class, 'empty')
? PHPUnit\Framework\TestSuite::empty('WP Codebox PHPUnit Tests')
: new PHPUnit\Framework\TestSuite('WP Codebox PHPUnit Tests');
PHPUnit 10 through current PHPUnit expose TestSuite::empty() and keep the constructor private. PHPUnit 9 has a public constructor and no empty() factory.
The discovered-class path also currently calls $suite->addTestSuite($class_name). PHPUnit 10+ requires a ReflectionClass; PHPUnit 9 accepts either a class name or ReflectionClass, so passing the existing $ref is compatible across both API generations.
Acceptance criteria
- Update plugin and WordPress-core generated harnesses.
- Add generated-code assertions covering the public factory fallback.
- Add focused execution coverage with a private-constructor TestSuite double proving discovered test files reach execution.
- Preserve distinct
STAGE_FAIL / STAGE_FATAL infrastructure reporting versus test assertion failures.
Summary
The generated
wordpress.phpunitPlayground harness crashes duringload_testswith PHPUnit 10+ because it directly constructsPHPUnit\Framework\TestSuite, whose constructor is private in those versions.Downstream report: Extra-Chill/homeboy-extensions#2258.
Reproduction
A Homeboy WordPress release gate using WP Codebox 0.12.14 installed WordPress and dependencies and discovered 46
*Test.phpfiles, then failed before any component test ran:The defect remains on current
mainat both generated harness sites:packages/runtime-playground/src/phpunit-command-handlers.ts:1273(phpunitRunCode)packages/runtime-playground/src/phpunit-command-handlers.ts:1592(corePhpunitRunCode)Both emit
new PHPUnit\Framework\TestSuite(...).Compatibility approach
Use the public factory when available, preserving PHPUnit 9 compatibility:
PHPUnit 10 through current PHPUnit expose
TestSuite::empty()and keep the constructor private. PHPUnit 9 has a public constructor and noempty()factory.The discovered-class path also currently calls
$suite->addTestSuite($class_name). PHPUnit 10+ requires aReflectionClass; PHPUnit 9 accepts either a class name orReflectionClass, so passing the existing$refis compatible across both API generations.Acceptance criteria
STAGE_FAIL/STAGE_FATALinfrastructure reporting versus test assertion failures.