Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions features/behat-steps.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ Feature: Test that WP-CLI Behat steps work as expected
Hello World
"""

Scenario: Test "Given a file" step with quoted path containing spaces
Given an empty directory
And a "test with spaces.txt" file:
"""
Hello World with Spaces
"""
Then the "test with spaces.txt" file should exist
And the "test with spaces.txt" file should contain:
"""
Hello World with Spaces
"""

Scenario: Test "Given a cache file" step
Given a WP installation
And an empty cache
Expand All @@ -57,6 +69,19 @@ Feature: Test that WP-CLI Behat steps work as expected
Cached content
"""

Scenario: Test "Given a cache file" step with quoted path containing spaces
Given a WP installation
And an empty cache
And a "test cache with spaces.txt" cache file:
"""
Cached Content with Spaces
"""
Then the "{SUITE_CACHE_DIR}/test cache with spaces.txt" file should exist
And the "{SUITE_CACHE_DIR}/test cache with spaces.txt" file should contain:
"""
Cached Content with Spaces
"""

Scenario: Test string replacement in file
Given an empty directory
And a config.txt file:
Expand Down
4 changes: 2 additions & 2 deletions src/Context/GivenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ public function given_an_empty_cache(): void {
*
* @access public
*
* @Given /^an? ([^\s]+) (file|cache file):$/
* @Given /^an? ("[^"]+"|[^\s]+) (file|cache file):$/
*
* @param string $path
* @param string $type
* @param PyStringNode $content
*/
public function given_a_specific_file( $path, $type, PyStringNode $content ): void {
$path = $this->replace_variables( (string) $path );
$path = trim( $this->replace_variables( (string) $path ), '"' );
$content = $this->replace_variables( (string) $content ) . "\n";
$full_path = 'cache file' === $type
? $this->variables['SUITE_CACHE_DIR'] . "/$path"
Expand Down
2 changes: 1 addition & 1 deletion src/Context/ThenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public function then_stdout_stderr_should_be_a_specific_version_string( $stream,
* @param string $expected Expected content.
*/
public function then_a_specific_file_folder_should_exist( $path, $type, $strictly, $action, $expected = null ): void {
$path = $this->replace_variables( $path );
$path = trim( $this->replace_variables( $path ), '"' );

// If it's a relative path, make it relative to the current test dir.
if ( ! Path::is_absolute( $path ) ) {
Expand Down
Loading