定制 friends-of-behat/variadic-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Install it:

    $ composer require friends-of-behat/variadic-extension --dev
  2. 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))
        );
  3. 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);
        }
    }

统计信息

  • 总下载量: 6.41M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 227
  • 点击次数: 12
  • 依赖项目数: 509
  • 推荐数: 0

GitHub 信息

  • Stars: 227
  • Watchers: 4
  • Forks: 8
  • 开发语言: Gherkin

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固