Skip to content

Commit 246a236

Browse files
committed
stub out php command tests
1 parent 62b8faf commit 246a236

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/ChildProcess/ChildProcessTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
});
2121
});
2222

23+
it('can start a php command', function () {
24+
ChildProcess::artisan("-r 'sleep(5);'", 'some-alias', ['baz' => 'zah']);
25+
26+
Http::assertSent(function (Request $request) {
27+
return $request->url() === 'http://localhost:4000/api/child-process/start' &&
28+
$request['alias'] === 'some-alias' &&
29+
$request['cmd'] === [PHP_BINARY, '-r', "'sleep(5);'"] &&
30+
$request['cwd'] === base_path() &&
31+
$request['env'] === ['baz' => 'zah'];
32+
});
33+
});
34+
2335
it('can start a artisan command', function () {
2436
ChildProcess::artisan('foo:bar', 'some-alias', ['baz' => 'zah']);
2537

@@ -40,6 +52,14 @@
4052
Http::assertSent(fn (Request $request) => $request['cmd'] === ['foo', 'baz']);
4153
});
4254

55+
it('accepts either a string or a array as php command argument', function () {
56+
ChildProcess::artisan(" 'sleep(5);'", 'some-alias');
57+
Http::assertSent(fn (Request $request) => $request['cmd'] === [PHP_BINARY, '-r', "'sleep(5);'"]);
58+
59+
ChildProcess::artisan(['-r', "'sleep(5);'"], 'some-alias');
60+
Http::assertSent(fn (Request $request) => $request['cmd'] === [PHP_BINARY, '-r', "'sleep(5);'"]);
61+
});
62+
4363
it('accepts either a string or a array as artisan command argument', function () {
4464
ChildProcess::artisan('foo:bar', 'some-alias');
4565
Http::assertSent(fn (Request $request) => $request['cmd'] === [PHP_BINARY, 'artisan', 'foo:bar']);
@@ -85,6 +105,11 @@
85105
Http::assertSent(fn (Request $request) => $request['persistent'] === true);
86106
});
87107

108+
it('can mark a php command as persistent', function () {
109+
ChildProcess::php("-r 'sleep(5);'", 'some-alias', persistent: true);
110+
Http::assertSent(fn (Request $request) => $request['persistent'] === true);
111+
});
112+
88113
it('can mark a artisan command as persistent', function () {
89114
ChildProcess::artisan('foo:bar', 'some-alias', persistent: true);
90115
Http::assertSent(fn (Request $request) => $request['persistent'] === true);

0 commit comments

Comments
 (0)