Skip to content

Extract and unit-test BootstrapManager::getTestDirPath() #56

Description

@remyperona

🤖 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

  1. 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.
  2. 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/.
  3. (Optionally, b1) Make setupConstants() internally idempotent by wrapping each define() in its own if ( ! defined() ) check for defense-in-depth.

Acceptance Criteria

  • New getTestDirPath() function exists, is documented, and is called by setupConstants()
  • New unit test file covers: no path= override (defaults to Tests/Unit and Tests/Integration), explicit path= override, trailing-slash handling
  • All existing tests pass (no regressions in setupConstants() behavior)
  • Test fixture files follow the repo's naming and structure conventions

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions