value)->toBe('ls -la') ->and($command->toString())->toBe('ls -la') ->and($command->isArray())->toBeFalse(); }); it('can be created from array', function () { $command = Command::fromArray(['ls', '-la']); expect($command->value)->toBe(['ls', '-la']) ->and($command->isArray())->toBeTrue(); }); it('escapes array commands when converting to string', function () { $command = Command::fromArray(['echo', 'hello world']); expect($command->toString())->toBe("'echo' 'hello world'"); }); it('throws exception for empty string command', function () { Command::fromString(''); })->throws(InvalidArgumentException::class, 'Command string cannot be empty'); it('throws exception for empty array command', function () { Command::fromArray([]); })->throws(InvalidArgumentException::class, 'Command array cannot be empty'); it('handles special characters in array commands', function () { $command = Command::fromArray(['echo', '$USER']); $string = $command->toString(); expect($string)->toContain('$USER'); }); });