Repository navigation
Tests: Add unit tests for wp_is_maintenance_mode() - #14474
shail-mehta wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The tests match the helper’s behavior, include cleanup, and have no identified blocking issues.
No open issues 🎉
What changed in this PR
Adds dedicated PHPUnit coverage for wp_is_maintenance_mode() as part of ticket #65819, without changing production code.
Changes:
- Tests missing, fresh, and expired maintenance files.
- Covers installation mode, scrape credentials, and filter behavior.
- Adds fixture cleanup and state restoration.
| File | Description |
|---|---|
| tests/phpunit/tests/load/wpIsMaintenanceMode.php | Adds maintenance-mode tests and fixture lifecycle helpers. |
Review effort: Balanced
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| * @param int $upgrading Unix timestamp. | ||
| */ | ||
| private function write_maintenance_file( $upgrading ) { | ||
| file_put_contents( ABSPATH . '.maintenance', '<?php $upgrading = ' . (int) $upgrading . ";\n" ); |
There was a problem hiding this comment.
Optional note: this writes a real .maintenance file into ABSPATH, because wp_is_maintenance_mode() hard-codes that path. tear_down() removes it. If a run stops partway, though, the file stays, and the next bootstrap would stop in maintenance mode for up to 10 minutes. A short comment here would help the next person who sees that.
What
Trac ticket: #65819
Adds unit tests for
wp_is_maintenance_mode()intests/phpunit/tests/load/wpIsMaintenanceMode.php.Covers a missing/expired
.maintenancefile, a fresh file, installing mode, scrape credentials, and theenable_maintenance_modefilter.Test-only change.
Why
This helper has had no dedicated PHPUnit coverage. Fits the #65819 missing-coverage track, and no open PR covers it.
How
.maintenancefile intear_down()enable_maintenance_modefilterTesting instructions
Use of AI Tools