MockSandbox implements the same CanExecuteCommand contract.
Use MockSandbox for deterministic command execution tests.
MockSandbox implements the same CanExecuteCommand contract.
use Cognesy\Sandbox\Data\ExecResult;
use Cognesy\Sandbox\Testing\MockSandbox;
$sandbox = MockSandbox::withResponses([
'php -v' => [
new ExecResult(stdout: 'PHP 8.3', stderr: '', exitCode: 0, duration: 0.01),
],
]);
// @doctest id="c8b0"
$result = $sandbox->execute(['php', '-v']);
echo $result->stdout();
// @doctest id="1933"
$commands = $sandbox->commands();
// @doctest id="e032"