|
20 | 20 | });
|
21 | 21 | });
|
22 | 22 |
|
| 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 | + |
23 | 35 | it('can start a artisan command', function () {
|
24 | 36 | ChildProcess::artisan('foo:bar', 'some-alias', ['baz' => 'zah']);
|
25 | 37 |
|
|
40 | 52 | Http::assertSent(fn (Request $request) => $request['cmd'] === ['foo', 'baz']);
|
41 | 53 | });
|
42 | 54 |
|
| 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 | + |
43 | 63 | it('accepts either a string or a array as artisan command argument', function () {
|
44 | 64 | ChildProcess::artisan('foo:bar', 'some-alias');
|
45 | 65 | Http::assertSent(fn (Request $request) => $request['cmd'] === [PHP_BINARY, 'artisan', 'foo:bar']);
|
|
85 | 105 | Http::assertSent(fn (Request $request) => $request['persistent'] === true);
|
86 | 106 | });
|
87 | 107 |
|
| 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 | + |
88 | 113 | it('can mark a artisan command as persistent', function () {
|
89 | 114 | ChildProcess::artisan('foo:bar', 'some-alias', persistent: true);
|
90 | 115 | Http::assertSent(fn (Request $request) => $request['persistent'] === true);
|
|
0 commit comments