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

orchestral / testbench-core / 13766805279

10 Mar 2025 02:13PM UTC coverage: 93.171% (+0.09%) from 93.085%
13766805279

push

github

web-flow
[7.x] Add `Orchestra\Testbench\Foundation\Actions\RemoteCommand`. (#326)

* Add `Orchestra\Testbench\Foundation\Actions\RemoteCommand`.

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

15 of 17 new or added lines in 2 files covered. (88.24%)

1378 of 1479 relevant lines covered (93.17%)

62.85 hits per line

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

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

3
namespace Orchestra\Testbench\Foundation\Actions;
4

5
use Illuminate\Support\Arr;
6
use Illuminate\Support\ProcessUtils;
7
use Symfony\Component\Process\Process;
8

9
use function Orchestra\Testbench\defined_environment_variables;
10
use function Orchestra\Testbench\php_binary;
11

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

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

37
        Arr::add($env, 'TESTBENCH_PACKAGE_REMOTE', '(true)');
10✔
38

39
        $process = Process::fromShellCommandline(
10✔
40
            command: Arr::join([php_binary(true), ProcessUtils::escapeArgument($commander), ...Arr::wrap($command)], ' '),
10✔
41
            cwd: $this->workingPath,
10✔
42
            env: array_merge(defined_environment_variables(), $env)
10✔
43
        );
10✔
44

45
        if (\is_bool($this->tty)) {
10✔
NEW
46
            $process->setTty($this->tty);
×
47
        }
48

49
        return $process;
10✔
50
    }
51
}
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