GitHub - FriendsOfBehat/VariadicExtension: 🍺 Extension adding variadic arguments support to Behat 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); } }