/
CliHelper.php
51 lines (43 loc) · 1.67 KB
/
CliHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Codeception\Module;
// here you can define custom functions for CliGuy
class CliHelper extends \Codeception\Module
{
public function _beforeSuite($settings = [])
{
$this->debug('Building actor classes for claypit');
$this->getModule('Cli')->runShellCommand('php ' . codecept_root_dir() . 'codecept build -c ' . codecept_data_dir() . 'claypit');
}
public function _before(\Codeception\TestInterface $test)
{
codecept_debug('creating dirs');
$this->getModule('Filesystem')->copyDir(codecept_data_dir() . 'claypit', codecept_data_dir() . 'sandbox');
}
public function _after(\Codeception\TestInterface $test)
{
codecept_debug('deleting dirs');
$this->getModule('Filesystem')->deleteDir(codecept_data_dir() . 'sandbox');
chdir(\Codeception\Configuration::projectDir());
}
public function executeCommand($command, $fail = true, $phpOptions = '')
{
$this->getModule('Cli')->runShellCommand('php ' . $phpOptions . ' ' . \Codeception\Configuration::projectDir() . 'codecept ' . $command . ' -n', $fail);
}
public function executeFailCommand($command)
{
$this->getModule('Cli')->runShellCommand('php '.\Codeception\Configuration::projectDir().'codecept '.$command.' -n', false);
}
public function grabFromOutput($regex)
{
$match = [];
$found = preg_match($regex, $this->getModule('Cli')->output, $match);
if (!$found) {
return '';
}
return $match[1];
}
public function seeDirFound($dir)
{
$this->assertTrue(is_dir($dir) && file_exists($dir), "Directory does not exist");
}
}