Skip to content

Commit

Permalink
Merge pull request #35 from loic425/feature/document-variadic-in-a-re…
Browse files Browse the repository at this point in the history
…gex-expression

[Documentation] Using Variadic in an expression containing a regex
  • Loading branch information
lchrusciel authored Dec 9, 2023
2 parents a9efc05 + 3b4ae57 commit e011461
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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"

0 comments on commit e011461

Please sign in to comment.