Conversation
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
There was a problem hiding this comment.
Code Review
This pull request refactors the maintenance mode feature tests by replacing inline wp eval commands with wp eval-file and external setup files, which improves readability and avoids shell escaping issues. The feedback suggests further improving the test structure by refactoring the repeated logic for numeric timestamps into a Scenario Outline with an Examples table.
| Scenario: Check maintenance mode status when numeric timestamp is used. | ||
|
|
||
| When I run `wp eval "file_put_contents('.maintenance', '<?php \$upgrading=' . ( time() + 100 ) . ';'); "` | ||
| Given a setup_num.php file: | ||
| """ | ||
| <?php | ||
| file_put_contents('.maintenance', '<?php $upgrading=' . ( time() + 100 ) . ';'); | ||
| """ | ||
| When I run `wp eval-file setup_num.php` | ||
| And I run `wp maintenance-mode is-active` | ||
| Then the return code should be 0 | ||
|
|
||
| When I run `wp eval "file_put_contents('.maintenance', '<?php \$upgrading =' . ( time() + 100 ) . ';') ; "` | ||
| Given a setup_num_space.php file: | ||
| """ | ||
| <?php | ||
| file_put_contents('.maintenance', '<?php $upgrading =' . ( time() + 100 ) . ';') ; | ||
| """ | ||
| When I run `wp eval-file setup_num_space.php` | ||
| And I run `wp maintenance-mode is-active` | ||
| Then the return code should be 0 | ||
|
|
||
| When I run `wp eval "file_put_contents('.maintenance', '<?php \$upgrading= ' . ( time() + 100 ) . ';'); "` | ||
| Given a setup_num_space2.php file: | ||
| """ | ||
| <?php | ||
| file_put_contents('.maintenance', '<?php $upgrading= ' . ( time() + 100 ) . ';'); | ||
| """ | ||
| When I run `wp eval-file setup_num_space2.php` | ||
| And I run `wp maintenance-mode is-active` | ||
| Then the return code should be 0 |
There was a problem hiding this comment.
This scenario repeats the same testing logic three times with minor variations. To improve maintainability and readability, you can refactor this using a Scenario Outline with an Examples table. This makes it clearer what variations are being tested and makes it easier to add more test cases in the future.
Scenario Outline: Check maintenance mode status when numeric timestamp is used with different spacing
Given a <file_name> file:
"""
<?php
<php_code>
"""
When I run `wp eval-file <file_name>`
And I run `wp maintenance-mode is-active`
Then the return code should be 0
Examples:
| file_name | php_code |
| setup_num.php | file_put_contents('.maintenance', '<?php $upgrading=' . ( time() + 100 ) . ';'); |
| setup_num_space.php | file_put_contents('.maintenance', '<?php $upgrading =' . ( time() + 100 ) . ';') ; |
| setup_num_space2.php | file_put_contents('.maintenance', '<?php $upgrading= ' . ( time() + 100 ) . ';'); |
There was a problem hiding this comment.
Pull request overview
Updates the Behat feature test for the maintenance-mode command to avoid shell-quoting issues by moving inline wp eval "..." one-liners into wp eval-file scripts, improving Windows compatibility.
Changes:
- Replace inline
wp eval "file_put_contents(...)"steps with generatedsetup*.phpfiles. - Execute those scripts via
wp eval-fileto create.maintenancein the desired formats for the scenarios.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
No description provided.