29/05
2017
Wallogit.com
2017 © Pedro Peláez
A simple library for parsing and searching in Behat contexts., (*1)
The intention of this library is to create autocomplete functions within the php language server using the language server protocol developer by Microsoft., (*2)
However, this could be usefull in other scenario's as well., (*3)
To fetch the step defenitions for a given class:, (*4)
$behat_parser_library = new Parser(); $class = \tests\FeatureContext::class; $behat_parser_library->readClassForStepDefinitions($class); $available_steps = $behat_parser_library->getAllStepDefinitions();
You can also use an array of classes:, (*5)
$behat_parser_library = new Parser(); $classes = [ \tests\FeatureContext::class, \tests\CustomContext::class, ]; $behat_parser_library->readClassesForStepDefinitions($class); $available_steps = $behat_parser_library->getAllStepDefinitions();
Then you can invoke the matcher to search for specific steps:, (*6)
$behat_parser_matcher = new Matcher($behat_parser_library);
$matching_result = $behat_parser_matcher->findStepContaining('I am using');