| 1 | <?php |
||
| 5 | class HookContext extends BaseContext implements Context |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @BeforeScenario |
||
| 9 | */ |
||
| 10 | public function initialize() |
||
| 11 | { |
||
| 12 | self::$workingDirectory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'etl'.DIRECTORY_SEPARATOR; |
||
| 13 | } |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @AfterScenario |
||
| 17 | */ |
||
| 18 | public function cleanup() |
||
| 19 | { |
||
| 20 | $this->clearDirectory(self::$workingDirectory); |
||
| 21 | } |
||
| 22 | |||
| 23 | private function clearDirectory($path) |
||
| 24 | { |
||
| 25 | $files = scandir($path); |
||
| 26 | array_shift($files); |
||
| 27 | array_shift($files); |
||
| 28 | |||
| 29 | foreach ($files as $file) { |
||
| 30 | $file = $path.DIRECTORY_SEPARATOR.$file; |
||
| 31 | if (is_dir($file)) { |
||
| 32 | $this->clearDirectory($file); |
||
| 33 | } else { |
||
| 34 | unlink($file); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | rmdir($path); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |