Skip to content

Commit feaafdd

Browse files
quickie
1 parent 11cb1fd commit feaafdd

11 files changed

Lines changed: 191 additions & 5 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
php: ["8.1", "8.2", "8.3"]
1919
symfony: ["^5.4", "^6.4", "^7.4"]
20-
behat: ["^3.10"]
20+
behat: ["^3.8"]
2121
dependencies: ["lowest", "highest"]
2222
exclude:
2323
- symfony: "^7.4"

behat.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(new Profile('default'))
1313
->withSuite(
1414
(new Suite('default'))
15+
->withPaths(__DIR__ . '/features/attributes')
1516
->withContexts(TestContext::class)
1617
)
1718
);

behat.yml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
default:
22
suites:
33
default:
4+
paths:
5+
- '%paths.base%/features/annotations'
46
contexts:
57
- FriendsOfBehat\TestContext\Context\TestContext

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
],
1111
"require": {
1212
"php": "^8.1",
13-
"behat/behat": "^3.10 || ^4.0",
13+
"behat/behat": "^3.8 || ^4.0",
1414
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.4 || ^8.0"
1515
},
1616
"require-dev": {
17-
"friends-of-behat/test-context": "^1.0"
17+
"friends-of-behat/test-context": "dev-master"
1818
},
1919
"extra": {
2020
"branch-alias": {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Feature: Transforming variadic arguments in step definitions
2+
In order to make Behat steps definitions cleaner and more readable
3+
As a Behat User
4+
I want to have transformed 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+
* @Transform /^(\w+)$/
23+
*/
24+
public function transform($string)
25+
{
26+
return strtoupper($string);
27+
}
28+
29+
/**
30+
* @When /^I pass "(\w+)" and "(\w+)" as arguments$/
31+
* @When I pass :firstArgument, :secondArgument and :thirdArgument
32+
*/
33+
public function iPass(...$arguments)
34+
{
35+
printf('Arguments: %s', join(', ', $arguments));
36+
}
37+
}
38+
"""
39+
40+
Scenario: Transforming variadic arguments in step definitions with a regex
41+
Given a feature file "features/variadic_arguments_support.feature" containing:
42+
"""
43+
Feature: Transforming variadic arguments in step definitions
44+
45+
Scenario: Transforming variadic arguments in step definitions
46+
When I pass "foo" and "bar" as arguments
47+
"""
48+
When I run Behat
49+
Then it should pass with "Arguments: FOO, BAR"
50+
51+
Scenario: Transforming variadic arguments in step definitions without regex
52+
Given a feature file "features/variadic_arguments_support.feature" containing:
53+
"""
54+
Feature: Transforming variadic arguments in step definitions
55+
56+
Scenario: Transforming variadic arguments in step definitions
57+
When I pass "one", "two" and "three"
58+
"""
59+
When I run Behat
60+
Then it should pass with "Arguments: ONE, TWO, THREE"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
* @When I pass :firstArgument and :secondArgument as arguments to :subject
32+
*/
33+
public function iPassToSubject($subject, ...$arguments)
34+
{
35+
printf('Number of arguments passed to %s: %d', $subject, count($arguments));
36+
}
37+
}
38+
"""
39+
40+
Scenario: Using two variadic arguments as the only ones
41+
Given a feature file "features/variadics_arguments_support.feature" containing:
42+
"""
43+
Feature: Passing arguments
44+
45+
Scenario: Passing two arguments
46+
When I pass "foo" and "bar" as arguments
47+
"""
48+
When I run Behat
49+
Then it should pass with "Number of passed arguments: 2"
50+
51+
Scenario: Using three variadic arguments as the only ones
52+
Given a feature file "features/variadics_arguments_support.feature" containing:
53+
"""
54+
Feature: Passing arguments
55+
56+
Scenario: Passing three arguments
57+
When I pass "foo", "bar" and "baz" as arguments
58+
"""
59+
When I run Behat
60+
Then it should pass with "Number of passed arguments: 3"
61+
62+
Scenario: Using variadic arguments together with regular one
63+
Given a feature file "features/variadics_arguments_support.feature" containing:
64+
"""
65+
Feature: Passing two variadic arguments and one regular argument
66+
67+
Scenario: Passing two variadic arguments and one regular argument
68+
When I pass "foo" and "bar" as arguments to method
69+
70+
"""
71+
When I run Behat
72+
Then it should pass with "Number of arguments passed to method: 2"
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"

features/transforming_variadic_arguments_in_step_definitions.feature renamed to features/attributes/transforming_variadic_arguments_in_step_definitions.feature

File renamed without changes.

features/using_variadic_arguments_in_steps_definitions_with_named_parameters.feature renamed to features/attributes/using_variadic_arguments_in_steps_definitions_with_named_parameters.feature

File renamed without changes.

features/using_variadic_arguments_in_steps_definitions_with_not_named_parameters.feature renamed to features/attributes/using_variadic_arguments_in_steps_definitions_with_not_named_parameters.feature

File renamed without changes.

0 commit comments

Comments
 (0)