Skip to content

Commit d6ccedb

Browse files
committed
Split features, rework naming & implementation
1 parent 0ad380c commit d6ccedb

3 files changed

+104
-64
lines changed

features/using_variadic_arguments_in_behat_steps_definitions.feature

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Feature: Using variadic arguments in steps definitions with named parameters
2+
In order to make Behat steps definitions cleaner and more readable
3+
As a Behat User
4+
I want to use variadic arguments in these
5+
6+
Background:
7+
Given a Behat configuration containing:
8+
"""
9+
default:
10+
extensions:
11+
FriendsOfBehat\VariadicExtension: ~
12+
"""
13+
And a context file "features/bootstrap/FeatureContext.php" containing:
14+
"""
15+
<?php
16+
17+
use Behat\Behat\Context\Context;
18+
19+
class FeatureContext implements Context
20+
{
21+
/**
22+
* @When I pass :firstArgument and :secondArgument as arguments
23+
* @When I pass :firstArgument, :secondArgument and :thirdArgument as arguments
24+
*/
25+
public function iPass(...$arguments)
26+
{
27+
printf('Number of passed arguments: %d', count($arguments));
28+
}
29+
}
30+
"""
31+
32+
Scenario: Using two variadic arguments as the only ones
33+
Given a feature file "features/variadics_arguments_support.feature" containing:
34+
"""
35+
Feature: Passing arguments
36+
37+
Scenario: Passing two arguments
38+
When I pass "foo" and "bar" as arguments
39+
"""
40+
When I run Behat
41+
Then it should pass with "Number of passed arguments: 2"
42+
43+
Scenario: Using three variadic arguments as the only ones
44+
Given a feature file "features/variadics_arguments_support.feature" containing:
45+
"""
46+
Feature: Passing arguments
47+
48+
Scenario: Passing three arguments
49+
When I pass "foo", "bar" and "baz" as arguments
50+
"""
51+
When I run Behat
52+
Then it should pass with "Number of passed arguments: 3"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Feature: Using variadic arguments in Behat steps definitions with not named parameters
2+
In order to make Behat steps definitions cleaner and more readable
3+
As a Behat User
4+
I want to use variadic arguments in these
5+
6+
Background:
7+
Given a Behat configuration containing:
8+
"""
9+
default:
10+
extensions:
11+
FriendsOfBehat\VariadicExtension: ~
12+
"""
13+
And a context file "features/bootstrap/FeatureContext.php" containing:
14+
"""
15+
<?php
16+
17+
use Behat\Behat\Context\Context;
18+
19+
class FeatureContext implements Context
20+
{
21+
/**
22+
* @When /^I pass "(\w+)" and "(\w+)" as arguments$/
23+
* @When /^I pass "(\w+)", "(\w+)" and "(\w+)" as arguments$/
24+
*/
25+
public function iPass(...$arguments)
26+
{
27+
printf('Number of passed arguments: %d', count($arguments));
28+
}
29+
}
30+
"""
31+
32+
Scenario: Using two variadic arguments as the only ones
33+
Given a feature file "features/variadic_arguments_support.feature" containing:
34+
"""
35+
Feature: Passing arguments
36+
37+
Scenario: Passing two arguments
38+
When I pass "foo" and "bar" as arguments
39+
"""
40+
When I run Behat
41+
Then it should pass with "Number of passed arguments: 2"
42+
43+
Scenario: Using three variadic arguments as the only ones
44+
Given a feature file "features/variadic_arguments_support.feature" containing:
45+
"""
46+
Feature: Passing arguments
47+
48+
Scenario: Passing three arguments
49+
When I pass "foo", "bar" and "baz" as arguments
50+
"""
51+
When I run Behat
52+
Then it should pass with "Number of passed arguments: 3"

0 commit comments

Comments
 (0)