Skip to content

Instantly share code, notes, and snippets.

@everzet everzet/gherkin_usage.php
Last active Aug 29, 2015

Embed
What would you like to do?
Usage of Behat\Gherkin 2.3
<?php
$keywords = new Behat\Gherkin\Keywords\CachedArrayKeywords('/path/to/gherkin_lib/i18n.php');
$lexer = new Behat\Gherkin\Lexer($keywords);
$parser = new Behat\Gherkin\Parser($lexer);
$gherkin = new Behat\Gherkin();
$gherkin->addLoader(new Behat\Gherkin\Loader\DirectoryLoader($gherkin));
$gherkin->addLoader(new Behat\Gherkin\Loader\GherkinFileLoader($parser));
$gherkin->setBasePath(__DIR__ . '/features');
/**
* @var FeatureNode[]
*
* @see https://github.com/Behat/Gherkin/blob/2.3/src/Behat/Gherkin/Node/FeatureNode.php
*/
$features = $gherkin->load('/absolute/path/to/your.feature'); // feature at absolute path
$features = $gherkin->load('relative/path/to/your.feature'); // feature at relative path (relative to base path)
$features = $gherkin->load('relative/path/to/your.feature:25'); // feature with all scenarios removed except one starting at line 25
$features = $gherkin->load('some/feature/directory'); // all features in provided directory
@naxhh

This comment has been minimized.

Copy link

commented Apr 8, 2014

Idk if is my set-up but this: $gherkin = new Behat\Gherkin(); for me is:

$gherkin = new Behat\Gherkin\Gherkin();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.