diff --git a/README.md b/README.md index d0d7c03..51dcc3c 100644 --- a/README.md +++ b/README.md @@ -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); + } + } ``` diff --git a/features/transforming_variadic_arguments_in_step_definitions.feature b/features/transforming_variadic_arguments_in_step_definitions.feature index e933a8b..5db5e22 100644 --- a/features/transforming_variadic_arguments_in_step_definitions.feature +++ b/features/transforming_variadic_arguments_in_step_definitions.feature @@ -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) { @@ -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 @@ -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"