Request: control Strict Mode per test
Đá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
- 45/100
Hướng nghiên cứu
Bắt đầu trong php/WP_Mock.php bằng cách đọc activateStrictMode() và strictMode(), sau đó kiểm tra các lệnh gọi strict mode trong WP_Mock/Hook.php và WP_Mock/Functions/Handler.php. Xem lại TestCase::setUp() và FeatureContext::forceStrictModeOn() để hiểu hành vi reset. Được xem là hoàn tất khi từng test có thể kiểm soát strict mode mà không làm trạng thái đó rò rỉ sang các test khác, với coverage cho hành vi được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Feature request
Currently, in my bootstrap.php I typically use WP_Mock::activateStrictMode().
I would like to disable strict mode for some tests, in particular where I use WP_Mock::expectActionAdded(). Often, a function that adds one action adds many, but I will only be interested in testing that one add_action() I've most recently added.
With strict mode on, other add_action/add_filter calls without their corresponding WP_Mock::expectActionAdded() result in:
Unexpected use of add_action for action init with callback BrianHenryIE\Example::init
Proposed solution
Add a public setter on WP_Mock::$__strict_mode() that can be used during individual tests, then in TestCase::setUp() reset strict mode to the configured/default value.
WP_Mock::activateStrictMode() only allows setting it before boostrap, and the documentation says it has to be enabled before bootstrap, but WP_Mock::strictMode() is only actually used in one, two places that don't read to me like it would matter.
The feature tests are already enabling/disabling it as desired in FeatureContext::forceStrictModeOn().
- Ngôn ngữ chính
- PHP
- Star
- 714
- Fork
- 72
- 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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 10up/wp_mock
-
`expectActionAdded( array( Functions::type( class-string ), 'method' ) )` fails when same method name used twiceCó thể đã có người làm @faisalahammad đã nhận 126 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
-
PHPCS reporting error on dependent library nikic/php-parser, hamcrest/hamcrest-phpCó thể đã có người làm @faisalahammad đã nhận 126 ngày trước. Đang mởDependencies
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Pass in Closure for HooksCó thể đã có người làm @faisalahammad đã nhận 126 ngày trước. Đang mởEnhancement Question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Compatibility with PHPUnit 10Đang mởDependencies PHPUnit
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Issue tương tự
-
wpvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
10up/autoshare-for-twitter#438 ·
-
wpvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
10up/Ad-Refresh-Control#240 ·
-
wpvc
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Backend bug severity: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
RunningJoke/allipunkte#74 ·