1 | <?php |
||
11 | class FeatureContext implements Context |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $phpBin; |
||
17 | /** |
||
18 | * @var Process |
||
19 | */ |
||
20 | private $process; |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $workingDir; |
||
25 | |||
26 | /** |
||
27 | * Cleans test folders in the temporary directory. |
||
28 | * |
||
29 | * @BeforeSuite |
||
30 | * @AfterSuite |
||
31 | */ |
||
32 | public static function cleanTestFolders() |
||
38 | |||
39 | /** |
||
40 | * Prepares test folders in the temporary directory. |
||
41 | * |
||
42 | * @BeforeScenario |
||
43 | */ |
||
44 | public function prepareTestFolders() |
||
60 | |||
61 | /** |
||
62 | * Creates a file with specified name and context in current workdir. |
||
63 | * |
||
64 | * @Given /^(?:there is )?a file named "([^"]*)" with:$/ |
||
65 | * |
||
66 | * @param string $filename name of the file (relative path) |
||
67 | * @param PyStringNode $content PyString string instance |
||
68 | */ |
||
69 | public function aFileNamedWith($filename, PyStringNode $content) |
||
74 | |||
75 | /** |
||
76 | * Moves user to the specified path. |
||
77 | * |
||
78 | * @Given /^I am in the "([^"]*)" path$/ |
||
79 | * |
||
80 | * @param string $path |
||
81 | */ |
||
82 | public function iAmInThePath($path) |
||
86 | |||
87 | /** |
||
88 | * Checks whether a file at provided path exists. |
||
89 | * |
||
90 | * @Given /^file "([^"]*)" should exist$/ |
||
91 | * |
||
92 | * @param string $path |
||
93 | */ |
||
94 | public function fileShouldExist($path) |
||
98 | |||
99 | /** |
||
100 | * Sets specified ENV variable |
||
101 | * |
||
102 | * @When /^"BEHAT_PARAMS" environment variable is set to:$/ |
||
103 | * |
||
104 | * @param PyStringNode $value |
||
105 | */ |
||
106 | public function iSetEnvironmentVariable(PyStringNode $value) |
||
110 | |||
111 | /** |
||
112 | * Runs behat command with provided parameters |
||
113 | * |
||
114 | * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/ |
||
115 | * |
||
116 | * @param string $argumentsString |
||
117 | */ |
||
118 | public function iRunBehat($argumentsString = '') |
||
143 | |||
144 | /** |
||
145 | * Checks whether previously ran command passes|fails with provided output. |
||
146 | * |
||
147 | * @Then /^it should (fail|pass) with:$/ |
||
148 | * |
||
149 | * @param string $success "fail" or "pass" |
||
150 | * @param PyStringNode $text PyString text instance |
||
151 | */ |
||
152 | public function itShouldPassWith($success, PyStringNode $text) |
||
157 | |||
158 | /** |
||
159 | * Checks whether previously runned command passes|failes with no output. |
||
160 | * |
||
161 | * @Then /^it should (fail|pass) with no output$/ |
||
162 | * |
||
163 | * @param string $success "fail" or "pass" |
||
164 | */ |
||
165 | public function itShouldPassWithNoOutput($success) |
||
170 | |||
171 | /** |
||
172 | * Checks whether specified file exists and contains specified string. |
||
173 | * |
||
174 | * @Then /^"([^"]*)" file should contain:$/ |
||
175 | * |
||
176 | * @param string $path file path |
||
177 | * @param PyStringNode $text file content |
||
178 | */ |
||
179 | public function fileShouldContain($path, PyStringNode $text) |
||
192 | |||
193 | /** |
||
194 | * Checks whether specified content and structure of the xml is correct without worrying about layout. |
||
195 | * |
||
196 | * @Then /^"([^"]*)" file xml should be like:$/ |
||
197 | * |
||
198 | * @param string $path file path |
||
199 | * @param PyStringNode $text file content |
||
200 | */ |
||
201 | public function fileXmlShouldBeLike($path, PyStringNode $text) |
||
214 | |||
215 | |||
216 | /** |
||
217 | * Checks whether last command output contains provided string. |
||
218 | * |
||
219 | * @Then the output should contain: |
||
220 | * |
||
221 | * @param PyStringNode $text PyString text instance |
||
222 | */ |
||
223 | public function theOutputShouldContain(PyStringNode $text) |
||
227 | |||
228 | private function getExpectedOutput(PyStringNode $expectedText) |
||
253 | |||
254 | /** |
||
255 | * Checks whether previously ran command failed|passed. |
||
256 | * |
||
257 | * @Then /^it should (fail|pass)$/ |
||
258 | * |
||
259 | * @param string $success "fail" or "pass" |
||
260 | */ |
||
261 | public function itShouldFail($success) |
||
277 | |||
278 | /** |
||
279 | * Checks whether the file is valid according to an XML schema. |
||
280 | * |
||
281 | * @Then /^the file "([^"]+)" should be a valid document according to "([^"]+)"$/ |
||
282 | * |
||
283 | * @param string $xmlFile |
||
284 | * @param string $schemaPath relative to features/bootstrap/schema |
||
285 | */ |
||
286 | public function xmlShouldBeValid($xmlFile, $schemaPath) |
||
293 | |||
294 | private function getExitCode() |
||
298 | |||
299 | private function getOutput() |
||
313 | |||
314 | private function createFile($filename, $content) |
||
321 | |||
322 | private function createDirectory($path) |
||
328 | |||
329 | private function moveToNewPath($path) |
||
338 | |||
339 | private static function clearDirectory($path) |
||
356 | } |
||
357 |