/** * @dataProvider providerFeatureInText */ public function testDumpFeature($initialContent) { $lexer = new \Behat\Gherkin\Lexer($this->keywords); $parser = new \Behat\Gherkin\Parser($lexer); $feature = $parser->parse($initialContent); $dumper = new Dumper($this->keywords); $this->assertEquals($initialContent, $dumper->dumpFeature($feature)); }
\t\t\t| Volume | 13 | tra | | Mileage | 400 |lalala | Scenario: Users Given I create these users: | name | age | | jeff | 101 | | jaap | 16 | | john | 3 | FEATURE; header('Content-type: text/plain'); $keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array('en' => array('feature' => 'Feature', 'background' => 'Background', 'scenario' => 'Scenario', 'scenario_outline' => 'Scenario Outline', 'examples' => 'Examples', 'given' => 'Given', 'when' => 'When', 'then' => 'Then', 'and' => 'And', 'but' => 'But'))); $lexer = new Behat\Gherkin\Lexer($keywords); $parser = new Behat\Gherkin\Parser($lexer); try { $feature = $parser->parse($feature); } catch (Exception $ex) { echo $ex->getMessage() . "\n"; exit; } foreach ($feature->getScenarios() as $scenario) { if ($scenario instanceof OutlineNode) { echo $scenario->getExampleTable() . "\n\n"; } elseif ($scenario instanceof ScenarioNode) { foreach ($scenario->getSteps() as $step) { foreach ($step->getArguments() as $argument) { if ($argument instanceof TableNode) { echo $argument . "\n\n"; } } // print_r($step);
function load($feature_file) { App::import('Vendor', 'gherkin'); $keywords = new Behat\Gherkin\Keywords\CachedArrayKeywords(ROOT . DS . APP_DIR . DS . 'vendors/gherkin/i18n.php'); $lexer = new Behat\Gherkin\Lexer($keywords); $parser = new Behat\Gherkin\Parser($lexer); $feature = $parser->parse(file_get_contents($feature_file)); $case = new FeatureTestCase($feature->getTitle()); $case->setBackground($feature->getBackground()); $case->setScenarios($feature->getScenarios()); return $case; }