Skip to content

Commit 506a20a

Browse files
Switch tests to use site-secrets instead of user-switching (#389)
* Switch tests to use `site-secrets` instead of `user-switching` User Switching increased its minimum supported PHP version, and started breaking our tests. Time to use Daniel's plugin instead! Sorry John. * Remove unused variable to fix PHPCS warning * Drop Jetpack because it fails tests * Update command description
1 parent 7118325 commit 506a20a

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

features/plugin-activate.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Feature: Activate WordPress plugins
3535
And the return code should be 1
3636

3737
Scenario: Activate all when one plugin is hidden by "all_plugins" filter
38-
Given I run `wp plugin install user-switching`
38+
Given I run `wp plugin install site-secrets`
3939
And a wp-content/mu-plugins/hide-us-plugin.php file:
4040
"""
4141
<?php
@@ -46,7 +46,7 @@ Feature: Activate WordPress plugins
4646
*/
4747
4848
add_filter( 'all_plugins', function( $all_plugins ) {
49-
unset( $all_plugins['user-switching/user-switching.php'] );
49+
unset( $all_plugins['site-secrets/site-secrets.php'] );
5050
return $all_plugins;
5151
} );
5252
"""
@@ -59,7 +59,7 @@ Feature: Activate WordPress plugins
5959
"""
6060
And STDOUT should not contain:
6161
"""
62-
Plugin 'user-switching' activated.
62+
Plugin 'site-secrets' activated.
6363
"""
6464

6565
@require-php-7

features/plugin-install.feature

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,48 +113,48 @@ Feature: Install WordPress plugins
113113
Scenario: Return code is 1 when one or more plugin installations fail
114114
Given a WP install
115115

116-
When I try `wp plugin install user-switching user-switching-not-a-plugin`
116+
When I try `wp plugin install site-secrets site-secrets-not-a-plugin`
117117
Then STDERR should contain:
118118
"""
119119
Warning:
120120
"""
121121
And STDERR should contain:
122122
"""
123-
user-switching-not-a-plugin
123+
site-secrets-not-a-plugin
124124
"""
125125
And STDERR should contain:
126126
"""
127127
Error: Only installed 1 of 2 plugins.
128128
"""
129129
And STDOUT should contain:
130130
"""
131-
Installing User Switching
131+
Installing Site Secrets
132132
"""
133133
And STDOUT should contain:
134134
"""
135135
Plugin installed successfully.
136136
"""
137137
And the return code should be 1
138138

139-
When I try `wp plugin install user-switching`
139+
When I try `wp plugin install site-secrets`
140140
Then STDOUT should be:
141141
"""
142142
Success: Plugin already installed.
143143
"""
144144
And STDERR should be:
145145
"""
146-
Warning: user-switching: Plugin already installed.
146+
Warning: site-secrets: Plugin already installed.
147147
"""
148148
And the return code should be 0
149149

150-
When I try `wp plugin install user-switching-not-a-plugin`
150+
When I try `wp plugin install site-secrets-not-a-plugin`
151151
Then STDERR should contain:
152152
"""
153153
Warning:
154154
"""
155155
And STDERR should contain:
156156
"""
157-
user-switching-not-a-plugin
157+
site-secrets-not-a-plugin
158158
"""
159159
And STDERR should contain:
160160
"""
@@ -222,18 +222,18 @@ Feature: Install WordPress plugins
222222
Scenario: Verify installed plugin activation
223223
Given a WP install
224224

225-
When I run `wp plugin install user-switching`
225+
When I run `wp plugin install site-secrets`
226226
Then STDOUT should not be empty
227227

228-
When I try `wp plugin install user-switching --activate`
228+
When I try `wp plugin install site-secrets --activate`
229229
Then STDERR should contain:
230230
"""
231-
Warning: user-switching: Plugin already installed.
231+
Warning: site-secrets: Plugin already installed.
232232
"""
233233

234234
And STDOUT should contain:
235235
"""
236-
Activating 'user-switching'...
237-
Plugin 'user-switching' activated.
236+
Activating 'site-secrets'...
237+
Plugin 'site-secrets' activated.
238238
Success: Plugin already installed.
239239
"""

features/plugin.feature

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -579,28 +579,27 @@ Feature: Manage WordPress plugins
579579
And these installed and active plugins:
580580
"""
581581
akismet
582-
jetpack
583-
user-switching
582+
site-secrets
584583
"""
585584
And a wp-content/mu-plugins/hide-us-plugin.php file:
586585
"""
587586
<?php
588587
/**
589-
* Plugin Name: Hide User Switchign on Production
590-
* Description: Hides the User Switching plugin on production sites
588+
* Plugin Name: Hide Site Secrets on Production
589+
* Description: Hides the Site Secrets plugin on production sites
591590
* Author: WP-CLI tests
592591
*/
593592
594593
add_filter( 'all_plugins', function( $all_plugins ) {
595-
unset( $all_plugins['user-switching/user-switching.php'] );
594+
unset( $all_plugins['site-secrets/site-secrets.php'] );
596595
return $all_plugins;
597596
} );
598597
"""
599598

600599
When I run `wp plugin list --fields=name`
601600
Then STDOUT should not contain:
602601
"""
603-
user-switching
602+
site-secrets
604603
"""
605604

606605
Scenario: Show dropins plugin list

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function install( $args, $assoc_args ) {
170170
// Don't attempt to rename ZIPs uploaded to the releases page or coming from a raw source.
171171
&& ! preg_match( '#github\.com/[^/]+/[^/]+/(?:releases/download|raw)/#', $slug ) ) {
172172

173-
$filter = function ( $source, $remote_source, $upgrader ) use ( $slug ) {
173+
$filter = function ( $source ) use ( $slug ) {
174174

175175
$slug_dir = Utils\basename( $this->parse_url_host_component( $slug, PHP_URL_PATH ), '.zip' );
176176

@@ -193,7 +193,7 @@ public function install( $args, $assoc_args ) {
193193

194194
return new WP_Error( 'wpcli_install_github', "Couldn't move Github-based project to appropriate directory." );
195195
};
196-
add_filter( 'upgrader_source_selection', $filter, 10, 3 );
196+
add_filter( 'upgrader_source_selection', $filter, 10 );
197197
}
198198

199199
if ( $file_upgrader->install( $slug ) ) {

0 commit comments

Comments
 (0)