extension-command/features/theme-install.feature
2026-03-09 19:08:36 +01:00

213 lines
5.6 KiB
Gherkin

Feature: Install WordPress themes
Background:
Given a WP install
And I run `wp theme delete --all --force`
Scenario: Return code is 1 when one or more theme installations fail
When I try `wp theme install twentytwelve twentytwelve-not-a-theme`
Then STDERR should contain:
"""
Warning:
"""
And STDERR should contain:
"""
twentytwelve-not-a-theme
"""
And STDERR should contain:
"""
Error: Only installed 1 of 2 themes.
"""
And STDOUT should contain:
"""
Installing Twenty Twelve
"""
And STDOUT should contain:
"""
Theme installed successfully.
"""
And the return code should be 1
When I try `wp theme install twentytwelve`
Then STDOUT should be:
"""
Success: Theme already installed.
"""
And STDERR should be:
"""
Warning: twentytwelve: Theme already installed.
"""
And the return code should be 0
When I try `wp theme install twentytwelve-not-a-theme`
Then STDERR should contain:
"""
Warning:
"""
And STDERR should contain:
"""
twentytwelve-not-a-theme
"""
And STDERR should contain:
"""
Error: No themes installed.
"""
And STDOUT should be empty
And the return code should be 1
Scenario: Ensure automatic parent theme installation uses http cacher
Given a WP install
And an empty cache
When I run `wp theme install moina`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 themes.
"""
And STDOUT should not contain:
"""
Using cached file
"""
When I run `wp theme uninstall moina`
Then STDOUT should contain:
"""
Success: Deleted 1 of 1 themes.
"""
When I run `wp theme install moina-blog`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 themes.
"""
And STDOUT should contain:
"""
This theme requires a parent theme.
"""
And STDOUT should contain:
"""
Using cached file
"""
Scenario: Verify installed theme activation
When I run `wp theme install twentytwelve`
Then STDOUT should not be empty
When I try `wp theme install twentytwelve --activate`
Then STDERR should contain:
"""
Warning: twentytwelve: Theme already installed.
"""
And STDOUT should contain:
"""
Activating 'twentytwelve'...
Success: Switched to 'Twenty Twelve' theme.
Success: Theme already installed.
"""
Scenario: Installation of multiple themes with activate
When I try `wp theme install twentytwelve twentyeleven --activate`
Then STDERR should contain:
"""
Warning: Only this single theme will be activated: twentyeleven
"""
When I run `wp theme list --field=name`
Then STDOUT should contain:
"""
twentyeleven
twentytwelve
"""
When I run `wp theme list --field=name --status=active`
Then STDOUT should contain:
"""
twentyeleven
"""
@require-php-7
Scenario: Can't install theme that requires a newer version of WordPress
Given a WP install
When I run `wp core download --version=6.4 --force`
And I run `rm -r wp-content/themes/*`
And I try `wp theme install twentytwentyfive`
Then STDERR should contain:
"""
Warning: twentytwentyfive: This theme does not work with your version of WordPress.
"""
And STDERR should contain:
"""
Error: No themes installed.
"""
@less-than-php-7.4 @require-wp-5.6
Scenario: Can't install theme that requires a newer version of PHP
Given a WP install
And I try `wp theme install oceanwp`
Then STDERR should contain:
"""
Warning: oceanwp: This theme does not work with your version of PHP.
"""
And STDERR should contain:
"""
Error: No themes installed.
"""
Scenario: Install theme using WordPress.org directory URL
When I run `wp theme install https://wordpress.org/themes/twentytwelve/`
Then STDOUT should contain:
"""
Detected WordPress.org themes directory URL, using slug: twentytwelve
"""
And the return code should be 0
When I run `wp theme list --name=twentytwelve --field=status`
Then STDOUT should be:
"""
inactive
"""
Scenario: Install and activate theme using WordPress.org directory URL
When I run `wp theme install https://wordpress.org/themes/twentyeleven/ --activate`
Then STDOUT should contain:
"""
Detected WordPress.org themes directory URL, using slug: twentyeleven
"""
And the return code should be 0
When I run `wp theme list --name=twentyeleven --field=status`
Then STDOUT should be:
"""
active
"""
Scenario: Install theme from a zip file with a custom --slug
Given a WP install
When I run `wp theme install https://downloads.wordpress.org/theme/twentytwelve.zip --slug=my-custom-theme`
Then STDOUT should contain:
"""
Renamed 'twentytwelve' to 'my-custom-theme'.
"""
And STDOUT should contain:
"""
Theme installed successfully.
"""
And the wp-content/themes/my-custom-theme directory should exist
And the return code should be 0
Scenario: Error when --slug is used with multiple themes
Given a WP install
When I try `wp theme install twentytwelve twentyeleven --slug=my-theme`
Then STDERR should contain:
"""
Error: The --slug option can only be used when installing a single item.
"""
And the return code should be 1