ConsoleHelper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 13
c 0
b 0
f 0
dl 0
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultConfig() 0 4 1
A getCli() 0 3 1
A runSprykerCommand() 0 4 1
A _after() 0 6 2
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);
0 ignored issues
show
Bug introduced by
The method runShellCommand() does not exist on Codeception\Module. It seems like you code against a sub-type of Codeception\Module such as Codeception\Module\Cli. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        $this->getCli()->/** @scrutinizer ignore-call */ runShellCommand($command);
Loading history...
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