From 8fe2681eefebe6f26b4c0d74ecbd0c4e14b12c01 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 4 Oct 2016 07:17:24 -0700 Subject: [PATCH 1/3] Failing test case for https://github.com/runcommand/sparks/issues/22 --- features/profile.feature | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/features/profile.feature b/features/profile.feature index bf82216..b101281 100644 --- a/features/profile.feature +++ b/features/profile.feature @@ -27,3 +27,12 @@ Feature: Basic profile usage | callback | time | | total | | And STDERR should be empty + + Scenario: Trailingslash provided URL to avoid canonical redirect + Given a WP install + + When I run `wp profile hook setup_theme --url=example.com` + Then STDERR should be empty + And STDOUT should be a table containing rows: + | callback | time | + | total | | From ee16b7982ac401b33c7b8130ea2db58786feefc2 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 4 Oct 2016 07:18:01 -0700 Subject: [PATCH 2/3] Trailingslash provided URL to avoid canonical redirect --- inc/class-command.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/class-command.php b/inc/class-command.php index 6db8dc7..ffef001 100644 --- a/inc/class-command.php +++ b/inc/class-command.php @@ -267,11 +267,13 @@ class Command { * Run the profiler against WordPress */ private function run_profiler() { - if ( ! isset( WP_CLI::get_runner()->config['url'] ) ) { - WP_CLI::add_wp_hook( 'muplugins_loaded', function(){ + WP_CLI::add_wp_hook( 'muplugins_loaded', function(){ + if ( $url = WP_CLI::get_runner()->config['url'] ) { + WP_CLI::set_url( trailingslashit( $url ) ); + } else { WP_CLI::set_url( home_url( '/' ) ); - }); - } + } + }); WP_CLI::add_hook( 'after_wp_config_load', function() { if ( defined( 'SAVEQUERIES' ) && ! SAVEQUERIES ) { WP_CLI::error( "'SAVEQUERIES' is defined as false, and must be true. Please check your wp-config.php" ); From 6e685729a64cd675d47ef567838469a63b711ea8 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 4 Oct 2016 07:27:31 -0700 Subject: [PATCH 3/3] Fix test setup for assertion --- features/profile.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/profile.feature b/features/profile.feature index b101281..2b36e25 100644 --- a/features/profile.feature +++ b/features/profile.feature @@ -31,7 +31,7 @@ Feature: Basic profile usage Scenario: Trailingslash provided URL to avoid canonical redirect Given a WP install - When I run `wp profile hook setup_theme --url=example.com` + When I run `wp profile hook setup_theme --url=example.com --fields=callback,time` Then STDERR should be empty And STDOUT should be a table containing rows: | callback | time |