1 | <?php |
||
18 | class ExampleNode implements ScenarioInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $title; |
||
24 | /** |
||
25 | * @var string[] |
||
26 | */ |
||
27 | private $tags; |
||
28 | /** |
||
29 | * @var StepNode[] |
||
30 | */ |
||
31 | private $outlineSteps; |
||
32 | /** |
||
33 | * @var string[] |
||
34 | */ |
||
35 | private $tokens; |
||
36 | /** |
||
37 | * @var integer |
||
38 | */ |
||
39 | private $line; |
||
40 | /** |
||
41 | * @var null|StepNode[] |
||
42 | */ |
||
43 | private $steps; |
||
44 | |||
45 | /** |
||
46 | * Initializes outline. |
||
47 | * |
||
48 | * @param string $title |
||
49 | * @param string[] $tags |
||
50 | * @param StepNode[] $outlineSteps |
||
51 | * @param string[] $tokens |
||
52 | * @param integer $line |
||
53 | */ |
||
54 | 3 | public function __construct($title, array $tags, $outlineSteps, array $tokens, $line) |
|
55 | { |
||
56 | 3 | $this->title = $title; |
|
57 | 3 | $this->tags = $tags; |
|
58 | 3 | $this->outlineSteps = $outlineSteps; |
|
59 | 3 | $this->tokens = $tokens; |
|
60 | 3 | $this->line = $line; |
|
61 | 3 | } |
|
62 | |||
63 | /** |
||
64 | * Returns node type string |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getNodeType() |
||
72 | |||
73 | /** |
||
74 | * Returns node keyword. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | public function getKeyword() |
||
82 | |||
83 | /** |
||
84 | * Returns example title. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getTitle() |
||
92 | |||
93 | /** |
||
94 | * Checks if outline is tagged with tag. |
||
95 | * |
||
96 | * @param string $tag |
||
97 | * |
||
98 | * @return Boolean |
||
99 | */ |
||
100 | public function hasTag($tag) |
||
104 | |||
105 | /** |
||
106 | * Checks if outline has tags (both inherited from feature and own). |
||
107 | * |
||
108 | * @return Boolean |
||
109 | */ |
||
110 | public function hasTags() |
||
114 | |||
115 | /** |
||
116 | * Returns outline tags (including inherited from feature). |
||
117 | * |
||
118 | * @return string[] |
||
119 | */ |
||
120 | public function getTags() |
||
124 | |||
125 | /** |
||
126 | * Checks if outline has steps. |
||
127 | * |
||
128 | * @return Boolean |
||
129 | */ |
||
130 | public function hasSteps() |
||
134 | |||
135 | /** |
||
136 | * Returns outline steps. |
||
137 | * |
||
138 | * @return StepNode[] |
||
139 | */ |
||
140 | 2 | public function getSteps() |
|
144 | |||
145 | /** |
||
146 | * Returns example tokens. |
||
147 | * |
||
148 | * @return string[] |
||
149 | */ |
||
150 | 1 | public function getTokens() |
|
154 | |||
155 | /** |
||
156 | * Returns outline declaration line number. |
||
157 | * |
||
158 | * @return integer |
||
159 | */ |
||
160 | 1 | public function getLine() |
|
164 | |||
165 | /** |
||
166 | * Creates steps for this example from abstract outline steps. |
||
167 | * |
||
168 | * @return StepNode[] |
||
169 | */ |
||
170 | 2 | protected function createExampleSteps() |
|
171 | { |
||
172 | 2 | $steps = array(); |
|
173 | 2 | foreach ($this->outlineSteps as $outlineStep) { |
|
174 | 2 | $keyword = $outlineStep->getKeyword(); |
|
175 | 2 | $keywordType = $outlineStep->getKeywordType(); |
|
176 | 2 | $text = $this->replaceTextTokens($outlineStep->getText()); |
|
177 | 2 | $args = $this->replaceArgumentsTokens($outlineStep->getArguments()); |
|
178 | 2 | $line = $outlineStep->getLine(); |
|
179 | |||
180 | 2 | $steps[] = new StepNode($keyword, $text, $args, $line, $keywordType); |
|
181 | 2 | } |
|
182 | |||
183 | 2 | return $steps; |
|
184 | } |
||
185 | |||
186 | /** |
||
187 | * Replaces tokens in arguments with row values. |
||
188 | * |
||
189 | * @param ArgumentInterface[] $arguments |
||
190 | * |
||
191 | * @return ArgumentInterface[] |
||
192 | */ |
||
193 | 2 | protected function replaceArgumentsTokens(array $arguments) |
|
206 | |||
207 | /** |
||
208 | * Replaces tokens in table with row values. |
||
209 | * |
||
210 | * @param TableNode $argument |
||
211 | * |
||
212 | * @return TableNode |
||
213 | */ |
||
214 | 1 | protected function replaceTableArgumentTokens(TableNode $argument) |
|
225 | |||
226 | /** |
||
227 | * Replaces tokens in PyString with row values. |
||
228 | * |
||
229 | * @param PyStringNode $argument |
||
230 | * |
||
231 | * @return PyStringNode |
||
232 | */ |
||
233 | 1 | protected function replacePyStringArgumentTokens(PyStringNode $argument) |
|
242 | |||
243 | /** |
||
244 | * Replaces tokens in text with row values. |
||
245 | * |
||
246 | * @param string $text |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | 2 | protected function replaceTextTokens($text) |
|
258 | } |
||
259 |