Skip to content

Commit e011461

Browse files
authored
Merge pull request #35 from loic425/feature/document-variadic-in-a-regex-expression
[Documentation] Using Variadic in an expression containing a regex
2 parents a9efc05 + 3b4ae57 commit e011461

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,16 @@ Adds variadic arguments support to Behat steps definitions.
3434
$this->saveProduct($this->createProduct($productName));
3535
}
3636
}
37+
38+
/**
39+
* @Given /^(this channel) has "([^"]+)", "([^"]+)", "([^"]+)" and "([^"]+)" products$/
40+
*/
41+
public function thisChannelHasProducts(ChannelInterface $channel, ...$productsNames)
42+
{
43+
foreach ($productsNames as $productName) {
44+
$product = $this->createProduct($productName, 0, $channel);
45+
46+
$this->saveProduct($product);
47+
}
48+
}
3749
```

features/transforming_variadic_arguments_in_step_definitions.feature

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Feature: Transforming variadic arguments in step definitions
2828
2929
/**
3030
* @When /^I pass "(\w+)" and "(\w+)" as arguments$/
31+
* @When I pass :firstArgument, :secondArgument and :thirdArgument
3132
*/
3233
public function iPass(...$arguments)
3334
{
@@ -36,7 +37,7 @@ Feature: Transforming variadic arguments in step definitions
3637
}
3738
"""
3839

39-
Scenario: Transforming variadic arguments in step definitions
40+
Scenario: Transforming variadic arguments in step definitions with a regex
4041
Given a feature file "features/variadic_arguments_support.feature" containing:
4142
"""
4243
Feature: Transforming variadic arguments in step definitions
@@ -46,3 +47,14 @@ Feature: Transforming variadic arguments in step definitions
4647
"""
4748
When I run Behat
4849
Then it should pass with "Arguments: FOO, BAR"
50+
51+
Scenario: Transforming variadic arguments in step definitions without regex
52+
Given a feature file "features/variadic_arguments_support.feature" containing:
53+
"""
54+
Feature: Transforming variadic arguments in step definitions
55+
56+
Scenario: Transforming variadic arguments in step definitions
57+
When I pass "one", "two" and "three"
58+
"""
59+
When I run Behat
60+
Then it should pass with "Arguments: ONE, TWO, THREE"

0 commit comments

Comments
 (0)