3 namespace Tests\Behat\Gherkin\Keywords;
5 use Behat\Gherkin\Keywords\ArrayKeywords;
6 use Behat\Gherkin\Keywords\KeywordsDumper;
8 class KeywordsDumperTest extends \PHPUnit_Framework_TestCase
12 protected function setUp()
14 $this->keywords = new ArrayKeywords(array(
16 'feature' => 'Feature',
17 'background' => 'Background',
18 'scenario' => 'Scenario',
19 'scenario_outline' => 'Scenario Outline|Scenario Template',
20 'examples' => 'Examples|Scenarios',
28 'feature' => 'Функционал|Фича',
29 'background' => 'Предыстория|Бэкграунд',
30 'scenario' => 'Сценарий|История',
31 'scenario_outline' => 'Структура сценария|Аутлайн',
32 'examples' => 'Значения',
33 'given' => 'Допустим',
42 public function testEnKeywordsDumper()
44 $dumper = new KeywordsDumper($this->keywords);
46 $dumped = $dumper->dump('en');
48 Feature: Internal operations
49 In order to stay secret
50 As a secret organization
51 We need to be able to erase past agents' memory
54 Given there is agent A
57 Scenario: Erasing agent memory
58 Given there is agent J
60 When I erase agent K's memory
61 Then there should be agent J
62 But there should not be agent K
64 (Scenario Outline|Scenario Template): Erasing other agents' memory
65 Given there is agent <agent1>
66 And there is agent <agent2>
67 When I erase agent <agent2>'s memory
68 Then there should be agent <agent1>
69 But there should not be agent <agent2>
76 $this->assertEquals($etalon, $dumped);
79 public function testRuKeywordsDumper()
81 $dumper = new KeywordsDumper($this->keywords);
83 $dumped = $dumper->dump('ru');
86 (Функционал|Фича): Internal operations
87 In order to stay secret
88 As a secret organization
89 We need to be able to erase past agents' memory
91 (Предыстория|Бэкграунд):
92 Допустим there is agent A
95 (Сценарий|История): Erasing agent memory
96 Допустим there is agent J
98 (Если|@) I erase agent K's memory
99 То there should be agent J
100 Но there should not be agent K
102 (Структура сценария|Аутлайн): Erasing other agents' memory
103 Допустим there is agent <agent1>
104 И there is agent <agent2>
105 (Если|@) I erase agent <agent2>'s memory
106 То there should be agent <agent1>
107 Но there should not be agent <agent2>
114 $this->assertEquals($etalon, $dumped);
117 public function testRuKeywordsCustomKeywordsDumper()
119 $dumper = new KeywordsDumper($this->keywords);
120 $dumper->setKeywordsDumperFunction(function ($keywords) {
121 return '<keyword>'.implode(', ', $keywords).'</keyword>';
124 $dumped = $dumper->dump('ru');
127 <keyword>Функционал, Фича</keyword>: Internal operations
128 In order to stay secret
129 As a secret organization
130 We need to be able to erase past agents' memory
132 <keyword>Предыстория, Бэкграунд</keyword>:
133 <keyword>Допустим</keyword> there is agent A
134 <keyword>И</keyword> there is agent B
136 <keyword>Сценарий, История</keyword>: Erasing agent memory
137 <keyword>Допустим</keyword> there is agent J
138 <keyword>И</keyword> there is agent K
139 <keyword>Если, @</keyword> I erase agent K's memory
140 <keyword>То</keyword> there should be agent J
141 <keyword>Но</keyword> there should not be agent K
143 <keyword>Структура сценария, Аутлайн</keyword>: Erasing other agents' memory
144 <keyword>Допустим</keyword> there is agent <agent1>
145 <keyword>И</keyword> there is agent <agent2>
146 <keyword>Если, @</keyword> I erase agent <agent2>'s memory
147 <keyword>То</keyword> there should be agent <agent1>
148 <keyword>Но</keyword> there should not be agent <agent2>
150 <keyword>Значения</keyword>:
155 $this->assertEquals($etalon, $dumped);
158 public function testExtendedVersionDumper()
160 $dumper = new KeywordsDumper($this->keywords);
162 $dumped = $dumper->dump('ru', false);
166 Функционал: Internal operations
167 In order to stay secret
168 As a secret organization
169 We need to be able to erase past agents' memory
172 Допустим there is agent A
175 Сценарий: Erasing agent memory
176 Допустим there is agent J
178 Если I erase agent K's memory
179 @ I erase agent K's memory
180 То there should be agent J
181 Но there should not be agent K
183 История: Erasing agent memory
184 Допустим there is agent J
186 Если I erase agent K's memory
187 @ I erase agent K's memory
188 То there should be agent J
189 Но there should not be agent K
191 Структура сценария: Erasing other agents' memory
192 Допустим there is agent <agent1>
193 И there is agent <agent2>
194 Если I erase agent <agent2>'s memory
195 @ I erase agent <agent2>'s memory
196 То there should be agent <agent1>
197 Но there should not be agent <agent2>
203 Аутлайн: Erasing other agents' memory
204 Допустим there is agent <agent1>
205 И there is agent <agent2>
206 Если I erase agent <agent2>'s memory
207 @ I erase agent <agent2>'s memory
208 То there should be agent <agent1>
209 Но there should not be agent <agent2>
217 Фича: Internal operations
218 In order to stay secret
219 As a secret organization
220 We need to be able to erase past agents' memory
223 Допустим there is agent A
226 Сценарий: Erasing agent memory
227 Допустим there is agent J
229 Если I erase agent K's memory
230 @ I erase agent K's memory
231 То there should be agent J
232 Но there should not be agent K
234 История: Erasing agent memory
235 Допустим there is agent J
237 Если I erase agent K's memory
238 @ I erase agent K's memory
239 То there should be agent J
240 Но there should not be agent K
242 Структура сценария: Erasing other agents' memory
243 Допустим there is agent <agent1>
244 И there is agent <agent2>
245 Если I erase agent <agent2>'s memory
246 @ I erase agent <agent2>'s memory
247 То there should be agent <agent1>
248 Но there should not be agent <agent2>
254 Аутлайн: Erasing other agents' memory
255 Допустим there is agent <agent1>
256 И there is agent <agent2>
257 Если I erase agent <agent2>'s memory
258 @ I erase agent <agent2>'s memory
259 То there should be agent <agent1>
260 Но there should not be agent <agent2>
268 $this->assertEquals($etalon, $dumped);