wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.
MIT License
90 stars 79 forks source link

Update the theme in feature tests #417

Closed tfirdaus closed 7 months ago

tfirdaus commented 7 months ago

This Pull Request updates the theme to install in the feature tests from p2 to twentytwelve since the p2 has been removed from WP.org repository.

Reference

ernilambar commented 7 months ago

In Given, if we could provide like

And I run `wp theme delete --all --force`

then we need not have to update much of code. This way we only need to replace theme slug in When.

tfirdaus commented 7 months ago

I tried using the --force flag, but it seems like it's going to require more updates to the initial feature spec than the necessary. Here's an example where it didn't work as expected. Since the twentytwenty theme is already installed, if I use --force, I'll have to change the output message from "Theme installed successfully." to "Theme updated successfully."

Screenshot 2024-04-24 at 1 49 11 PM

@ernilambar @swissspidy Thought on this. Do you think this is the preferable approach? Ideally I'd prefer to keep the updates to a minimum.

ernilambar commented 7 months ago

I think you added --force to the command in When. We should not be updating those arguments. You can add And I run wp theme delete --all --force in Given (after line 4) in theme-install.feature. (Apologies. I think I didn't make that clear in earlier comment)

swissspidy commented 7 months ago

There are still a lot of tests referencing p2. I'd probably start by replacing all of those with twentytwelve

tfirdaus commented 7 months ago

@ernilambar this error is a bit weird to me. Somehow it does not happen when I run this test in local. What do you think I did wrong here? It seems there are slight differences between the environment that missed in my local.

009 Scenario: Parent theme is active when its child is active # features/theme.feature:577
      And I run `wp theme delete twentytwelve --force`        # features/theme.feature:579
        $ wp theme delete twentytwelve --force
        Success: Theme already deleted.

If I did not run wp theme delete twentytwelve --force, it would throw:

001 Scenario: Parent theme is active when its child is active # features/theme.feature:577
      And I run `wp theme install twentytwelve`               # features/theme.feature:580
        $ wp theme install twentytwelve
        Success: Theme already installed.

        Warning: twentytwelve: Theme already installed.
tfirdaus commented 7 months ago

Thanks @ernilambar for your help on this PR 👏