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

orchestral / testbench-core / 17254102425

27 Aug 2025 12:42AM UTC coverage: 92.41% (-0.04%) from 92.453%
17254102425

push

github

crynobone
Fix `remote()` with serializable closure usage

caused by https://github.com/laravel/framework/pull/56757

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

4 of 5 new or added lines in 1 file covered. (80.0%)

1522 of 1647 relevant lines covered (92.41%)

75.77 hits per line

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

90.0
/src/Foundation/Process/RemoteCommand.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation\Process;
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\Sidekick\laravel_version_compare;
12
use function Orchestra\Testbench\defined_environment_variables;
13
use function Orchestra\Testbench\php_binary;
14

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

33
    /**
34
     * Execute the command.
35
     *
36
     * @param  (\Closure():(mixed))|array<int, string>|string  $command
37
     * @return \Orchestra\Testbench\Foundation\Process\ProcessDecorator
38
     */
39
    public function handle(string $commander, Closure|array|string $command): ProcessDecorator
40
    {
41
        $env = \is_string($this->env) ? ['APP_ENV' => $this->env] : $this->env;
12✔
42

43
        Arr::add($env, 'TESTBENCH_PACKAGE_REMOTE', '(true)');
12✔
44

45
        if ($command instanceof Closure) {
12✔
46
            $env['LARAVEL_INVOKABLE_CLOSURE'] = transform(serialize(new SerializableClosure($command)), function ($invokableClosure) {
1✔
47
                return laravel_version_compare('12.26.0', '<')
1✔
NEW
48
                    ? $invokableClosure
×
49
                    : base64_encode($invokableClosure);
1✔
50
            });
1✔
51

52
            $env['APP_KEY'] = $env['APP_KEY'] ?? config('app.key') ?? false;
1✔
53
            $commands = ['invoke-serialized-closure'];
1✔
54
        } else {
55
            $commands = Arr::wrap($command);
12✔
56
        }
57

58
        $process = Process::fromShellCommandline(
12✔
59
            command: Arr::join([php_binary(true), ProcessUtils::escapeArgument($commander), ...$commands], ' '),
12✔
60
            cwd: $this->workingPath,
12✔
61
            env: array_merge(defined_environment_variables(), $env)
12✔
62
        );
12✔
63

64
        if (\is_bool($this->tty)) {
12✔
65
            $process->setTty($this->tty);
×
66
        }
67

68
        return new ProcessDecorator($process, $command);
12✔
69
    }
70
}
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