https://github.com/friendsofbehat/variadicextension
🍺 Extension adding variadic arguments support to Behat steps definitions
https://github.com/friendsofbehat/variadicextension
behat behat-extension php variadic-arguments
Last synced: 9 months ago
JSON representation
🍺 Extension adding variadic arguments support to Behat steps definitions
- Host: GitHub
- URL: https://github.com/friendsofbehat/variadicextension
- Owner: FriendsOfBehat
- License: mit
- Created: 2016-08-25T19:56:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-30T11:29:04.000Z (about 2 years ago)
- Last Synced: 2024-10-15T02:32:20.344Z (over 1 year ago)
- Topics: behat, behat-extension, php, variadic-arguments
- Language: Gherkin
- Homepage:
- Size: 67.4 KB
- Stars: 226
- Watchers: 6
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Variadic Extension [](https://packagist.org/packages/friends-of-behat/variadic-extension) [](https://packagist.org/packages/friends-of-behat/variadic-extension) [](https://github.com/FriendsOfBehat/VariadicExtension/actions/workflows/build.yml) [](https://scrutinizer-ci.com/g/FriendsOfBehat/VariadicExtension/)
Adds variadic arguments support to Behat steps definitions.
## Usage
1. Install it:
```bash
$ composer require friends-of-behat/variadic-extension --dev
```
2. Enable it in your Behat configuration:
```yaml
# behat.yml
default:
# ...
extensions:
FriendsOfBehat\VariadicExtension: ~
```
3. You can use variadic arguments in steps definitions!
```php
/**
* @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);
}
}
```