friends-of-behat / variadic-extension
为 behat 上下文参数提供可变参数支持
v1.6.0
2024-01-30 11:13 UTC
Requires
- php: ^8.1
- behat/behat: ^3.8
- symfony/dependency-injection: ^5.4 || ^6.4 || ^7.0
Requires (Dev)
README
为 Behat 步骤定义添加可变参数支持。
用法
-
安装它
$ composer require friends-of-behat/variadic-extension --dev
-
在 Behat 配置中启用它
# behat.yml default: # ... extensions: FriendsOfBehat\VariadicExtension: ~
-
您可以在步骤定义中使用可变参数!
/** * @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); } }