Skip to content

Tests: improve Windows compatibility#41

Merged
swissspidy merged 1 commit intomainfrom
fix/windows-tests
Mar 28, 2026
Merged

Tests: improve Windows compatibility#41
swissspidy merged 1 commit intomainfrom
fix/windows-tests

Conversation

@swissspidy
Copy link
Copy Markdown
Member

No description provided.

@swissspidy swissspidy added this to the 2.1.4 milestone Mar 28, 2026
@swissspidy swissspidy requested a review from a team as a code owner March 28, 2026 11:40
Copilot AI review requested due to automatic review settings March 28, 2026 11:40
@github-actions
Copy link
Copy Markdown
Contributor

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:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

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:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added help-wanted Extra attention is needed scope:testing Related to testing labels Mar 28, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 81 to 108
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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 )  . ';'); |

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 generated setup*.php files.
  • Execute those scripts via wp eval-file to create .maintenance in the desired formats for the scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy merged commit d769c19 into main Mar 28, 2026
68 checks passed
@swissspidy swissspidy deleted the fix/windows-tests branch March 28, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help-wanted Extra attention is needed scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants