friends-of-behat/variadic-extension
Composer 安装命令:
composer require friends-of-behat/variadic-extension
包简介
Variadic support for behat context arguments
README 文档
README
Adds variadic arguments support to Behat steps definitions.
The why
In Behat, if you want a step definition to accept different numbers of arguments, you normally have to define separate methods for each variation. This quickly becomes repetitive and hard to maintain as the number of argument combinations grows.
This extension solves that by letting you use PHP's variadic syntax (...$args) in your step definitions.
A single method can capture many argument variations, keeping your context classes clean and concise.
Usage
-
Install it:
$ composer require friends-of-behat/variadic-extension --dev
-
Enable it in your Behat configuration:
# behat.yml default: # ... extensions: FriendsOfBehat\VariadicExtension: ~
or if you use a PHP-based configuration:
# behat.php use Behat\Config\Config; use Behat\Config\Extension; use Behat\Config\Profile; use FriendsOfBehat\VariadicExtension\ServiceContainer\VariadicExtension; return (new Config()) ->withProfile( (new Profile('default')) ->withExtension(new Extension(VariadicExtension::class)) );
-
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$/ * @Given /^(this channel) has "([^"]+)", "([^"]+)" and "([^"]+)" products$/ * @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); } }
friends-of-behat/variadic-extension 适用场景与选型建议
friends-of-behat/variadic-extension 是一款 基于 Gherkin 开发的 Composer 扩展包,目前已累计 6.41M 次下载、GitHub Stars 达 227, 最近一次更新时间为 2016 年 08 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 friends-of-behat/variadic-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 friends-of-behat/variadic-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6.41M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 227
- 点击次数: 19
- 依赖项目数: 509
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-25