Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Using Variadic in an expression containing a regex #35

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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ Adds variadic arguments support to Behat steps definitions.
$this->saveProduct($this->createProduct($productName));
}
}

/**
* @Given /^(this channel) has "([^"]+)", "([^"]+)", "([^"]+)" and "([^"]+)" products$/
*/
public function thisChannelHasProducts(ChannelInterface $channel, ...$productsNames)
{
foreach ($productsNames as $productName) {
$product = $this->createProduct($productName, 0, $channel);

$this->saveProduct($product);
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Feature: Transforming variadic arguments in step definitions

/**
* @When /^I pass "(\w+)" and "(\w+)" as arguments$/
* @When I pass :firstArgument, :secondArgument and :thirdArgument
*/
public function iPass(...$arguments)
{
Expand All @@ -36,7 +37,7 @@ Feature: Transforming variadic arguments in step definitions
}
"""

Scenario: Transforming variadic arguments in step definitions
Scenario: Transforming variadic arguments in step definitions with a regex
Given a feature file "features/variadic_arguments_support.feature" containing:
"""
Feature: Transforming variadic arguments in step definitions
Expand All @@ -46,3 +47,14 @@ Feature: Transforming variadic arguments in step definitions
"""
When I run Behat
Then it should pass with "Arguments: FOO, BAR"

Scenario: Transforming variadic arguments in step definitions without regex
Given a feature file "features/variadic_arguments_support.feature" containing:
"""
Feature: Transforming variadic arguments in step definitions

Scenario: Transforming variadic arguments in step definitions
When I pass "one", "two" and "three"
"""
When I run Behat
Then it should pass with "Arguments: ONE, TWO, THREE"
Loading