• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / testbench-core / 13780733903

11 Mar 2025 05:02AM UTC coverage: 92.613% (+0.1%) from 92.514%
13780733903

push

github

crynobone
Merge branch '9.x' into 10.x

19 of 21 new or added lines in 2 files covered. (90.48%)

1492 of 1611 relevant lines covered (92.61%)

74.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/src/Foundation/Actions/RemoteCommand.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation\Actions;
4

5
use Closure;
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\ProcessUtils;
8
use Laravel\SerializableClosure\SerializableClosure;
9
use Symfony\Component\Process\Process;
10

11
use function Orchestra\Testbench\defined_environment_variables;
12
use function Orchestra\Testbench\php_binary;
13

14
class RemoteCommand
15
{
16
    /**
17
     * Construct a new action.
18
     *
19
     * @param  string  $workingPath
20
     * @param  array<string, mixed>|string  $env
21
     * @param  bool|null  $tty
22
     */
23
    public function __construct(
24
        public string $workingPath,
25
        public array|string $env = [],
26
        public ?bool $tty = null,
27
    ) {}
12✔
28

29
    /**
30
     * Execute the command.
31
     *
32
     * @param  (\Closure():(mixed))|array<int, string>|string  $command
33
     * @return \Symfony\Component\Process\Process
34
     */
35
    public function handle(string $commander, Closure|array|string $command): Process
36
    {
37
        $env = \is_string($this->env) ? ['APP_ENV' => $this->env] : $this->env;
12✔
38

39
        Arr::add($env, 'TESTBENCH_PACKAGE_REMOTE', '(true)');
12✔
40

41
        if ($command instanceof Closure) {
12✔
42
            $env['LARAVEL_INVOKABLE_CLOSURE'] = serialize(new SerializableClosure($command));
1✔
43
            $env['APP_KEY'] = $env['APP_KEY'] ?? config('app.key') ?? false;
1✔
44
            $command = 'invoke-serialized-closure';
1✔
45
        }
46

47
        $process = Process::fromShellCommandline(
12✔
48
            command: Arr::join([php_binary(true), ProcessUtils::escapeArgument($commander), ...Arr::wrap($command)], ' '),
12✔
49
            cwd: $this->workingPath,
12✔
50
            env: array_merge(defined_environment_variables(), $env)
12✔
51
        );
12✔
52

53
        if (\is_bool($this->tty)) {
12✔
NEW
54
            $process->setTty($this->tty);
×
55
        }
56

57
        return $process;
12✔
58
    }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc