From 76da2171b50bda6b8f09f701911b9edeab60fe68 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 3 Mar 2021 19:19:43 +0000 Subject: [PATCH] Add yet more missing imports --- src/Context/GivenStepDefinitions.php | 6 ++++-- src/Context/Support.php | 8 ++++---- src/Context/ThenStepDefinitions.php | 3 +++ src/Context/WhenStepDefinitions.php | 9 +++++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Context/GivenStepDefinitions.php b/src/Context/GivenStepDefinitions.php index b9cd5f966..353d86253 100644 --- a/src/Context/GivenStepDefinitions.php +++ b/src/Context/GivenStepDefinitions.php @@ -4,7 +4,9 @@ use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\TableNode; +use RuntimeException; use WP_CLI\Process; +use WP_CLI\Utils; trait GivenStepDefinitions { @@ -20,7 +22,7 @@ public function given_an_empty_directory() { */ public function given_a_specific_directory( $empty_or_nonexistent, $dir ) { $dir = $this->replace_variables( $dir ); - if ( ! WP_CLI\Utils\is_path_absolute( $dir ) ) { + if ( ! Utils\is_path_absolute( $dir ) ) { $dir = $this->variables['RUN_DIR'] . "/$dir"; } @@ -187,7 +189,7 @@ public function given_a_download( TableNode $table ) { continue; } - Process::create( \WP_CLI\Utils\esc_cmd( 'curl -sSL %s > %s', $row['url'], $path ) )->run_check(); + Process::create( \Utils\esc_cmd( 'curl -sSL %s > %s', $row['url'], $path ) )->run_check(); } } diff --git a/src/Context/Support.php b/src/Context/Support.php index cf38f37bc..242fd03c3 100644 --- a/src/Context/Support.php +++ b/src/Context/Support.php @@ -98,13 +98,13 @@ protected function compare_contents( $expected, $actual ) { if ( is_object( $expected ) ) { foreach ( get_object_vars( $expected ) as $name => $value ) { - if ( ! compare_contents( $value, $actual->$name ) ) { + if ( ! $this->compare_contents( $value, $actual->$name ) ) { return false; } } } elseif ( is_array( $expected ) ) { foreach ( $expected as $key => $value ) { - if ( ! compare_contents( $value, $actual[ $key ] ) ) { + if ( ! $this->compare_contents( $value, $actual[ $key ] ) ) { return false; } } @@ -154,7 +154,7 @@ protected function check_that_json_string_contains_json_string( $actual_json, $e return false; } - return compare_contents( $expected_value, $actual_value ); + return $this->compare_contents( $expected_value, $actual_value ); } /** @@ -220,6 +220,6 @@ protected function check_that_yaml_string_contains_yaml_string( $actual_yaml, $e return false; } - return compare_contents( $expected_value, $actual_value ); + return $this->compare_contents( $expected_value, $actual_value ); } } diff --git a/src/Context/ThenStepDefinitions.php b/src/Context/ThenStepDefinitions.php index 9378dd082..186dd18a2 100644 --- a/src/Context/ThenStepDefinitions.php +++ b/src/Context/ThenStepDefinitions.php @@ -4,6 +4,9 @@ use Behat\Gherkin\Node\PyStringNode; use Behat\Gherkin\Node\TableNode; +use Exception; +use Requests; +use RuntimeException; trait ThenStepDefinitions { diff --git a/src/Context/WhenStepDefinitions.php b/src/Context/WhenStepDefinitions.php index 7b0f4ebb3..42f430eb6 100644 --- a/src/Context/WhenStepDefinitions.php +++ b/src/Context/WhenStepDefinitions.php @@ -3,6 +3,7 @@ namespace WP_CLI\Tests\Context; use WP_CLI\Process; +use Exception; trait WhenStepDefinitions { @@ -36,7 +37,7 @@ public function when_i_launch_in_the_background( $cmd ) { public function when_i_run( $mode, $cmd ) { $cmd = $this->replace_variables( $cmd ); $this->result = $this->wpcli_tests_invoke_proc( $this->proc( $cmd ), $mode ); - list($this->result->stdout, $this->email_sends) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); + list( $this->result->stdout, $this->email_sends ) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); } /** @@ -45,7 +46,7 @@ public function when_i_run( $mode, $cmd ) { public function when_i_run_from_a_subfolder( $mode, $cmd, $subdir ) { $cmd = $this->replace_variables( $cmd ); $this->result = $this->wpcli_tests_invoke_proc( $this->proc( $cmd, array(), $subdir ), $mode ); - list($this->result->stdout, $this->email_sends) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); + list( $this->result->stdout, $this->email_sends ) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); } /** @@ -53,12 +54,12 @@ public function when_i_run_from_a_subfolder( $mode, $cmd, $subdir ) { */ public function when_i_run_the_previous_command_again( $mode ) { if ( ! isset( $this->result ) ) { - throw new \Exception( 'No previous command.' ); + throw new Exception( 'No previous command.' ); } $proc = Process::create( $this->result->command, $this->result->cwd, $this->result->env ); $this->result = $this->wpcli_tests_invoke_proc( $proc, $mode ); - list($this->result->stdout, $this->email_sends) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); + list( $this->result->stdout, $this->email_sends ) = $this->wpcli_tests_capture_email_sends( $this->result->stdout ); } }