|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
|
9
|
|
|
|
|
10
|
|
|
namespace PyzTest\Zed\Console\Helper; |
|
11
|
|
|
|
|
12
|
|
|
use Codeception\Module; |
|
13
|
|
|
use Codeception\TestInterface; |
|
14
|
|
|
use Codeception\Util\FileSystem; |
|
15
|
|
|
use SprykerTest\Shared\Testify\Helper\ModuleHelperConfigTrait; |
|
16
|
|
|
|
|
17
|
|
|
class ConsoleHelper extends Module |
|
18
|
|
|
{ |
|
19
|
|
|
use ModuleHelperConfigTrait; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
*/ |
|
24
|
|
|
public const RUNNER = 'console_runner.php'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
public const SANDBOX_DIR = 'cli_sandbox/'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param \Codeception\TestInterface $test |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
public function _after(TestInterface $test): void // phpcs:ignore SlevomatCodingStandard.Functions.UnusedParameter |
|
37
|
|
|
{ |
|
38
|
|
|
foreach ($this->config['cleanup_dirs'] as $dir) { |
|
39
|
|
|
$dir = codecept_data_dir() . self::SANDBOX_DIR . $dir; |
|
40
|
|
|
$this->debugSection('Cleanup', $dir); |
|
41
|
|
|
FileSystem::deleteDir($dir); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param string $command |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
|
|
public function runSprykerCommand(string $command): void |
|
51
|
|
|
{ |
|
52
|
|
|
$command = 'php ' . codecept_data_dir() . self::RUNNER . " $command"; |
|
53
|
|
|
$this->getCli()->runShellCommand($command); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function setDefaultConfig(): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->config = [ |
|
62
|
|
|
'cleanup_dirs' => ['data', 'src'], |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return \Codeception\Module\Cli|\Codeception\Module |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function getCli() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getModule('Cli'); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|