X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fbehat%2Fgherkin%2Ftests%2FBehat%2FGherkin%2FParserTest.php;fp=vendor%2Fbehat%2Fgherkin%2Ftests%2FBehat%2FGherkin%2FParserTest.php;h=aff585cda24e6a85e611802e909b99115c6dfac1;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hp=0000000000000000000000000000000000000000;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68;p=yaffs-website diff --git a/vendor/behat/gherkin/tests/Behat/Gherkin/ParserTest.php b/vendor/behat/gherkin/tests/Behat/Gherkin/ParserTest.php new file mode 100644 index 000000000..aff585cda --- /dev/null +++ b/vendor/behat/gherkin/tests/Behat/Gherkin/ParserTest.php @@ -0,0 +1,147 @@ +parseEtalon($fixtureName . '.yml'); + $features = $this->parseFixture($fixtureName . '.feature'); + + $this->assertInternalType('array', $features); + $this->assertEquals(1, count($features)); + $fixture = $features[0]; + + $this->assertEquals($etalon, $fixture); + } + + public function testParserResetsTagsBetweenFeatures() + { + $parser = $this->getGherkinParser(); + + $parser->parse(<<parse(<<assertFalse($feature2->hasTags()); + } + + protected function getGherkinParser() + { + if (null === $this->gherkin) { + $keywords = new 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' + ), + 'ru' => array( + 'feature' => 'Функционал', + 'background' => 'Предыстория', + 'scenario' => 'Сценарий', + 'scenario_outline' => 'Структура сценария', + 'examples' => 'Значения', + 'given' => 'Допустим', + 'when' => 'То', + 'then' => 'Если', + 'and' => 'И', + 'but' => 'Но' + ), + 'ja' => array ( + 'feature' => 'フィーチャ', + 'background' => '背景', + 'scenario' => 'シナリオ', + 'scenario_outline' => 'シナリオアウトライン', + 'examples' => '例|サンプル', + 'given' => '前提<', + 'when' => 'もし<', + 'then' => 'ならば<', + 'and' => 'かつ<', + 'but' => 'しかし<' + ) + )); + $this->gherkin = new Parser(new Lexer($keywords)); + } + + return $this->gherkin; + } + + protected function getYamlParser() + { + if (null === $this->yaml) { + $this->yaml = new YamlFileLoader(); + } + + return $this->yaml; + } + + protected function parseFixture($fixture) + { + $file = __DIR__ . '/Fixtures/features/' . $fixture; + + return array($this->getGherkinParser()->parse(file_get_contents($file), $file)); + } + + protected function parseEtalon($etalon) + { + $features = $this->getYamlParser()->load(__DIR__ . '/Fixtures/etalons/' . $etalon); + $feature = $features[0]; + + return new FeatureNode( + $feature->getTitle(), + $feature->getDescription(), + $feature->getTags(), + $feature->getBackground(), + $feature->getScenarios(), + $feature->getKeyword(), + $feature->getLanguage(), + __DIR__ . '/Fixtures/features/' . basename($etalon, '.yml') . '.feature', + $feature->getLine() + ); + } +}