friends-of-behat/variadic-extension

Variadic support for behat context arguments

Installs: 3 254 606

Dependents: 426

Suggesters: 0

Security: 0

Stars: 225

Watchers: 6

Forks: 7

Open Issues: 1

Language:Gherkin

v1.5.0 2022-03-31 09:48 UTC

This package is auto-updated.

Last update: 2023-09-29 01:58:42 UTC


README

Adds variadic arguments support to Behat steps definitions.

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: ~
  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));
        }
    }