return $this->install_dir . '/' . $file;
}
+ public function get_cache_path( $file ) {
+ static $path;
+
+ if ( !$path ) {
+ $path = sys_get_temp_dir() . '/wp-cli-test-cache';
+ system( \WP_CLI\Utils\create_cmd( 'mkdir -p %s', $path ) );
+ }
+
+ return $path . '/' . $file;
+ }
+
+ public function download_file( $url, $path ) {
+ system( \WP_CLI\Utils\create_cmd( 'curl -sSL %s > %s', $url, $path ) );
+ }
+
private static function run_sql( $sql ) {
$dbuser = self::$db_settings['dbuser'];
$dbpass = self::$db_settings['dbpass'];
Then it should run without errors
And STDOUT should contain:
"""
- usage:
+ usage: wp core
"""
When I run `wp help core download`
When I run `wp help non-existent-command`
Then the return code should be 1
+
+ Scenario: Getting help for a third-party command
+ Given a WP install
+ And a google-sitemap-generator-cli plugin zip
+ And I run `wp plugin install --activate {PLUGIN_ZIP}`
+ And I run `wp plugin install --activate google-sitemap-generator`
+
+ When I run `wp help google-sitemap`
+ Then it should run without errors
+ And STDOUT should contain:
+ """
+ usage: wp google-sitemap
+ """
}
);
-$steps->Given('/^a P2 theme zip$/',
+$steps->Given( '/^a P2 theme zip$/',
function ( $world ) {
$zip_name = 'p2.1.0.1.zip';
- $cache_dir = sys_get_temp_dir() . '/wp-cli-test-cache';
- $world->variables['THEME_ZIP'] = $cache_dir . '/' . $zip_name;
+ $world->variables['THEME_ZIP'] = $world->get_cache_path( $zip_name );
$zip_url = 'http://wordpress.org/extend/themes/download/' . $zip_name;
- system( \WP_CLI\Utils\create_cmd( 'mkdir -p %s', $cache_dir ) );
+ $world->download_file( $zip_url, $world->variables['THEME_ZIP'] );
+ }
+);
+
+$steps->Given( '/^a google-sitemap-generator-cli plugin zip$/',
+ function ( $world ) {
+ $zip_url = 'https://github.com/wp-cli/google-sitemap-generator-cli/archive/master.zip';
+
+ $world->variables['PLUGIN_ZIP'] = $world->get_cache_path( 'google-sitemap-generator-cli.zip' );
- system( \WP_CLI\Utils\create_cmd( 'curl -s %s > %s', $zip_url,
- $world->variables['THEME_ZIP'] ) );
+ $world->download_file( $zip_url, $world->variables['PLUGIN_ZIP'] );
}
);