Closes #53: Move test-data config layer into TestCaseTrait - #58
Conversation
Adds $config, configTestData(), and loadTestDataConfig() to TestCaseTrait so Unit\TestCase and Integration\TestCase inherit the layer, letting consumers (e.g. mcp-oauth) drop their duplicated base TestCase.php. $config defaults to [] to match VirtualFilesystemTestTrait::$config and avoid the PHP fatal on trait/inherited-property composition in VirtualFilesystemTestCase. Closes #53 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Note Generated by the AI delivery pipeline (qa-engineer · Claude Opus 4.8). QA: ✅ PASS Validated on host (PHP 8.1.29, no Docker) via
Smoke test: Note (out of stated scope): the diff also touches |
|
Note Generated by the AI delivery pipeline (lead-reviewer · Claude Opus 4.8). Review: ✅ PASS Verified locally (PHP 8.3):
Nice-to-haves:
|
Closes #53 · Contributes to #30 (moving generic infrastructure into the library).
Description
Moves the test-data config layer —
$config,configTestData(),loadTestDataConfig()— from consumer plugins' duplicatedTests/{Unit,Integration}/TestCase.phpfiles into the sharedTestCaseTrait, right next to thegetTestData()they depend on. SinceUnit\TestCaseandIntegration\TestCasealreadyuse TestCaseTrait, they inherit the members automatically and consumers can extend the library's base classes directly instead of shipping their own boilerplate.What was done
src/TestCaseTrait.php— addedprotected $config = [];,configTestData()(data provider, lazily loads vialoadTestDataConfig()), andloadTestDataConfig()(resolves the fixture from the test's file path viaReflectionObject). Noset_up()hook (per the issue — it would collide with the differing Unit/Integration base-class signatures).src/Unit/TestCase.phporsrc/Integration/TestCase.php— they inherit transparently.Tests/Unit/TestCaseTrait/(Test_ConfigTestData,Test_LoadTestDataConfig) with fixtures underTests/Fixtures/TestCaseTrait/.Key design constraint
$configmust default to[]to matchVirtualFilesystemTestTrait's existingprotected $config = [];. BothUnit\VirtualFilesystemTestCaseandIntegration\VirtualFilesystemTestCaseextendTestCase(now inheritingTestCaseTrait::$config) and directlyuse VirtualFilesystemTestTrait— and PHP fatal-errors at class-declaration if a trait property and an inherited property of the same name differ in default value or visibility. The matching declaration avoids this; the existingTests/Integration/testHttpRequestTraitWithVirtualFilesystem.phpregression test guards it on CI.Type of change
Testing
Locally:
composer test-unit(124 tests / 326 assertions),composer phpcs,composer phpstan— all clean, no new baseline entries.