🤖 AI-generated — created by an automated pipeline. Review before acting on this.
Context
PR #55 (issue #52) made src/{Unit,Integration}/bootstrap.php self-locating via BootstrapManager::setupConstants(). During grooming, an optional testability refactor ("Option B") was deferred: extracting the test-directory default resolution logic into a dedicated helper function to improve unit test coverage. This is a nice-to-have enhancement that reduces maintenance burden in downstream repos (#30) while improving this package's own test coverage.
Dependencies
#52 / PR #55 (already shipped)
What needs to be done
- Extract the test-directory default resolution from
src/BootstrapManager::setupConstants() into a new protected static function getTestDirPath( $which_testsuite ) that returns the relative path (path= override if present, else 'Tests/' . ucfirst( $which_testsuite )), and have setupConstants() call it.
- Create a new per-method unit test
Tests/Unit/BootstrapManager/getTestDirPath.php with a Test_getTestDirPath class following the repo's one-class-per-method convention, with data providers under Tests/Fixtures/BootstrapManager/.
- (Optionally, b1) Make
setupConstants() internally idempotent by wrapping each define() in its own if ( ! defined() ) check for defense-in-depth.
Acceptance Criteria
Additional information
Why it matters: The setupConstants() path is process-global and irreversible; every process in this package's own suite pre-defines the constants via init-tests.php, leaving the default-path branch untested. Extracting a pure helper makes that branch testable using the same approach as getRootDir().
References: Contributes to #30 (reduce per-plugin test maintenance); follow-up to #52 / PR #55.
Context
PR #55 (issue #52) made
src/{Unit,Integration}/bootstrap.phpself-locating viaBootstrapManager::setupConstants(). During grooming, an optional testability refactor ("Option B") was deferred: extracting the test-directory default resolution logic into a dedicated helper function to improve unit test coverage. This is a nice-to-have enhancement that reduces maintenance burden in downstream repos (#30) while improving this package's own test coverage.Dependencies
#52 / PR #55 (already shipped)
What needs to be done
src/BootstrapManager::setupConstants()into a newprotected static function getTestDirPath( $which_testsuite )that returns the relative path (path=override if present, else'Tests/' . ucfirst( $which_testsuite )), and havesetupConstants()call it.Tests/Unit/BootstrapManager/getTestDirPath.phpwith aTest_getTestDirPathclass following the repo's one-class-per-method convention, with data providers underTests/Fixtures/BootstrapManager/.setupConstants()internally idempotent by wrapping eachdefine()in its ownif ( ! defined() )check for defense-in-depth.Acceptance Criteria
getTestDirPath()function exists, is documented, and is called bysetupConstants()path=override (defaults toTests/UnitandTests/Integration), explicitpath=override, trailing-slash handlingsetupConstants()behavior)Additional information
Why it matters: The
setupConstants()path is process-global and irreversible; every process in this package's own suite pre-defines the constants viainit-tests.php, leaving the default-path branch untested. Extracting a pure helper makes that branch testable using the same approach asgetRootDir().References: Contributes to #30 (reduce per-plugin test maintenance); follow-up to #52 / PR #55.