8000 gherkin:snippets generates stub function name for non-english feature… · Codeception/Codeception@3955bf1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3955bf1

Browse files
kuntashovDavertMik
authored andcommitted
gherkin:snippets generates stub function name for non-english features (#4132)
1 parent 978f12c commit 3955bf1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/Codeception/Lib/Generator/GherkinSnippets.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ public function addSnippet(StepNode $step)
115115
}
116116

117117
$methodName = preg_replace('~(\s+?|\'|\"|\W)~', '', ucwords(preg_replace('~"(.*?)"|\d+~', '', $step->getText())));
118+
if (empty($methodName)) {
119+
$methodName = 'step_' . substr(sha1($pattern), 0, 9);
120+
}
118121

119122
$this->snippets[] = (new Template($this->template))
120123
->place('type', $step->getKeywordType())

tests/cli/GherkinCest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,11 @@ public function runSameStepWithInlineAndPyStringArgument(CliGuy $I)
6565
$I->executeCommand('run scenario "PyStringArgumentExample.feature:Running step with PyString argument" --steps');
6666
$I->seeInShellOutput("Argument: First line\nSecond line");
6767
}
68+
69+
public function snippetsScenarioUtf8(CliGuy $I)
70+
{
71+
$I->executeCommand('gherkin:snippets scenario Utf8Example.feature');
72+
$I->seeInShellOutput('@Given я написал сценарий на языке :arg1');
73+
$I->seeInShellOutput('public function step_62e20dc62($arg1)');
74+
}
6875
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#language: ru
2+
3+
Функционал: Генерация сниппетов из сценариев на других языках
4+
Как пользователь
5+
Чтобы выполнить проверку сценариев на родном языке заказчика
6+
Я хочу иметь возможность генерировать сниппеты из них
7+
8+
Сценарий: Генерация сниппета из сценария на русском языке
9+
Допустим я написал сценарий на языке "RU_ru"

0 commit comments

Comments
 (0)
0