How to write Behat test/feature in PHP?
one text
Behat tests are usually written in Gherkin language but these are text files without any refactoring possible.
Example:
instead of writing feature file like:
Feature: ScopeBuilder
Scenario: test ScopeBuilder rendering of model scope
Given I am on "_unit-test/scope-builder.php"
Then rule "atk_fp_stat__a3b68d0c" operator is ">=" and value is "1000"
Then rule "atk_fp_stat__ff68957f" operator is "matches regular expression" and value is "[a-zA-Z]"
the answer should accept files like:
$countField = Field::getDbName('stat.count'); // atk_fp_stat__a3b68d0c
$nameField = Field::getDbName('stat.name'); // atk_fp_stat__ff68957f
return new Feature(
'ScopeBuilder',
new Scenario(
'test ScopeBuilder rendering of model scope',
new Step('Given I am on "_unit-test/scope-builder.php"'),
new Step('Then rule "' . $countField . '" operator is ">=" and value is "1000"'),
new Step('Then rule "' . $nameField . '" operator is "matches regular expression" and value is "[a-zA-Z]"')
)
);
The question is, how to convince Behat to scan for php files in specific directory and add testing scenarios defined in php files like in the example.
Source