Skip to content

Commit

Permalink
Merge pull request #106 from wp-cli/fix/add-yet-more-missing-imports
Browse files Browse the repository at this point in the history
Add yet more missing imports
  • Loading branch information
schlessera authored Mar 3, 2021
2 parents 7c1e9ad + 76da217 commit edf691c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Context/GivenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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";
}

Expand Down Expand Up @@ -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();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Context/Support.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );
}
}
3 changes: 3 additions & 0 deletions src/Context/ThenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Exception;
use Requests;
use RuntimeException;

trait ThenStepDefinitions {

Expand Down
9 changes: 5 additions & 4 deletions src/Context/WhenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace WP_CLI\Tests\Context;

use WP_CLI\Process;
use Exception;

trait WhenStepDefinitions {

Expand Down Expand Up @@ -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 );
}

/**
Expand All @@ -45,20 +46,20 @@ 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 );
}

/**
* @When /^I (run|try) the previous command again$/
*/
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 );
}
}

0 comments on commit edf691c

Please sign in to comment.