-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathMockRunner.php
More file actions
39 lines (31 loc) · 888 Bytes
/
MockRunner.php
File metadata and controls
39 lines (31 loc) · 888 Bytes
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
<?php
namespace ProcessMaker\ScriptRunners;
use Illuminate\Support\Str;
use Log;
use ProcessMaker\Exception\ScriptTimeoutException;
class MockRunner
{
public function __construct($scriptExecutor)
{
}
public function run($code, $data, $config, $timeout, $user)
{
if (app()->env !== 'testing') {
throw new \Exception('MockRunner is for tests only.');
}
if (config('simulate_timeout')) {
Log::error('Script timed out');
throw new ScriptTimeoutException('Script timed out');
}
putenv('HOST_URL=' . config('app.docker_host_url'));
if (Str::startsWith($code, '<?php')) {
$res = eval(str_replace('<?php', '', $code));
} else {
$res = ['response' => 1];
}
return ['output' => $res];
}
public function setTokenId()
{
}
}