Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Extract and unit-test BootstrapManager::getTestDirPath()

Đang mở
#56 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
php
Lĩnh vực
testing

Hướng nghiên cứu

Start in src/BootstrapManager at setupConstants(), and compare the existing getRootDir() testing approach. Add the per-method test at Tests/Unit/BootstrapManager/getTestDirPath.php with fixtures under Tests/Fixtures/BootstrapManager/, covering defaults, path= overrides, and trailing slashes. Run the existing test suite and confirm setupConstants() behavior remains unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement Made by AI

🤖 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.

Ngôn ngữ chính
PHP
Star
4
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wp-media/phpunit

Tất cả issue của wp-media/phpunit

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.