friends-of-behat / variadic-extension
Variadic support for behat context arguments
Installs: 4 584 305
Dependents: 469
Suggesters: 0
Security: 0
Stars: 226
Watchers: 6
Forks: 7
Open Issues: 1
Language:Gherkin
Requires
- php: ^8.1
- behat/behat: ^3.8
- symfony/dependency-injection: ^5.4 || ^6.4 || ^7.0
Requires (Dev)
README
Adds variadic arguments support to Behat steps definitions.
Usage
-
Install it:
$ composer require friends-of-behat/variadic-extension --dev
-
Enable it in your Behat configuration:
# behat.yml default: # ... extensions: FriendsOfBehat\VariadicExtension: ~
-
You can use variadic arguments in steps definitions!
/** * @Given the store has( also) :firstProductName and :secondProductName products * @Given the store has( also) :firstProductName, :secondProductName and :thirdProductName products * @Given the store has( also) :firstProductName, :secondProductName, :thirdProductName and :fourthProductName products */ public function theStoreHasProducts(...$productsNames) { foreach ($productsNames as $productName) { $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); } }