1 | <?php |
||
8 | class KeywordsDumperTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | private $keywords; |
||
11 | |||
12 | protected function setUp() |
||
13 | { |
||
14 | $this->keywords = new ArrayKeywords(array( |
||
15 | 'en' => array( |
||
16 | 'feature' => 'Feature', |
||
17 | 'background' => 'Background', |
||
18 | 'scenario' => 'Scenario', |
||
19 | 'scenario_outline' => 'Scenario Outline|Scenario Template', |
||
20 | 'examples' => 'Examples|Scenarios', |
||
21 | 'given' => 'Given', |
||
22 | 'when' => 'When', |
||
23 | 'then' => 'Then', |
||
24 | 'and' => 'And', |
||
25 | 'but' => 'But' |
||
26 | ), |
||
27 | 'ru' => array( |
||
28 | 'feature' => 'Функционал|Фича', |
||
29 | 'background' => 'Предыстория|Бэкграунд', |
||
30 | 'scenario' => 'Сценарий|История', |
||
31 | 'scenario_outline' => 'Структура сценария|Аутлайн', |
||
32 | 'examples' => 'Значения', |
||
33 | 'given' => 'Допустим', |
||
34 | 'when' => 'Если|@', |
||
35 | 'then' => 'То', |
||
36 | 'and' => 'И', |
||
37 | 'but' => 'Но' |
||
38 | ) |
||
39 | )); |
||
40 | } |
||
41 | |||
42 | public function testEnKeywordsDumper() |
||
43 | { |
||
44 | $dumper = new KeywordsDumper($this->keywords); |
||
45 | |||
46 | $dumped = $dumper->dump('en'); |
||
47 | $etalon = <<<GHERKIN |
||
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 |
||
52 | |||
53 | Background: |
||
54 | Given there is agent A |
||
55 | And there is agent B |
||
56 | |||
57 | Scenario: Erasing agent memory |
||
58 | Given there is agent J |
||
59 | And there is agent K |
||
60 | When I erase agent K's memory |
||
61 | Then there should be agent J |
||
62 | But there should not be agent K |
||
63 | |||
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> |
||
70 | |||
71 | (Examples|Scenarios): |
||
72 | | agent1 | agent2 | |
||
73 | | D | M | |
||
74 | GHERKIN; |
||
75 | |||
76 | $this->assertEquals($etalon, $dumped); |
||
77 | } |
||
78 | |||
79 | public function testRuKeywordsDumper() |
||
80 | { |
||
81 | $dumper = new KeywordsDumper($this->keywords); |
||
82 | |||
83 | $dumped = $dumper->dump('ru'); |
||
84 | $etalon = <<<GHERKIN |
||
85 | # language: 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 |
||
90 | |||
91 | (Предыстория|Бэкграунд): |
||
92 | Допустим there is agent A |
||
93 | И there is agent B |
||
94 | |||
95 | (Сценарий|История): Erasing agent memory |
||
96 | Допустим there is agent J |
||
97 | И there is agent K |
||
98 | (Если|@) I erase agent K's memory |
||
99 | То there should be agent J |
||
100 | Но there should not be agent K |
||
101 | |||
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> |
||
108 | |||
109 | Значения: |
||
110 | | agent1 | agent2 | |
||
111 | | D | M | |
||
112 | GHERKIN; |
||
113 | |||
114 | $this->assertEquals($etalon, $dumped); |
||
115 | } |
||
116 | |||
117 | public function testRuKeywordsCustomKeywordsDumper() |
||
118 | { |
||
119 | $dumper = new KeywordsDumper($this->keywords); |
||
120 | $dumper->setKeywordsDumperFunction(function ($keywords) { |
||
121 | return '<keyword>'.implode(', ', $keywords).'</keyword>'; |
||
122 | }); |
||
123 | |||
124 | $dumped = $dumper->dump('ru'); |
||
125 | $etalon = <<<GHERKIN |
||
126 | # language: 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 |
||
131 | |||
132 | <keyword>Предыстория, Бэкграунд</keyword>: |
||
133 | <keyword>Допустим</keyword> there is agent A |
||
134 | <keyword>И</keyword> there is agent B |
||
135 | |||
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 |
||
142 | |||
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> |
||
149 | |||
150 | <keyword>Значения</keyword>: |
||
151 | | agent1 | agent2 | |
||
152 | | D | M | |
||
153 | GHERKIN; |
||
154 | |||
155 | $this->assertEquals($etalon, $dumped); |
||
156 | } |
||
157 | |||
158 | public function testExtendedVersionDumper() |
||
270 | } |
||
271 |