Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions features/maintenance-mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ Feature: Manage maintenance mode of WordPress install.

Scenario: Check maintenance mode status when expression is used.

When I run `wp eval "file_put_contents('.maintenance', '<?php \$upgrading=(time()-601);'); "`
Given a setup.php file:
"""
<?php
file_put_contents('.maintenance', '<?php $upgrading=(time()-601);');
"""
When I run `wp eval-file setup.php`
And I try `wp maintenance-mode is-active`
Then the return code should be 1
And STDERR should contain:
Expand All @@ -75,14 +80,29 @@ Feature: Manage maintenance mode of WordPress install.

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
Comment on lines 81 to 108
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 )  . ';'); |

Loading