mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Support\Testing;
|
||||
|
||||
use App\Exceptions\SSHConnectionError;
|
||||
use App\Helpers\SSH;
|
||||
use Illuminate\Support\Traits\ReflectsClosures;
|
||||
use PHPUnit\Framework\Assert;
|
||||
@ -14,11 +15,25 @@ class SSHFake extends SSH
|
||||
|
||||
protected ?string $output;
|
||||
|
||||
protected bool $connectionWillFail = false;
|
||||
|
||||
public function __construct(?string $output = null)
|
||||
{
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
public function connectionWillFail(): void
|
||||
{
|
||||
$this->connectionWillFail = true;
|
||||
}
|
||||
|
||||
public function connect(bool $sftp = false): void
|
||||
{
|
||||
if ($this->connectionWillFail) {
|
||||
throw new SSHConnectionError('Connection failed');
|
||||
}
|
||||
}
|
||||
|
||||
public function exec(string|array $commands, string $log = '', ?int $siteId = null): string
|
||||
{
|
||||
if ($log) {
|
||||
@ -45,6 +60,11 @@ public function exec(string|array $commands, string $log = '', ?int $siteId = nu
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function upload(string $local, string $remote): void
|
||||
{
|
||||
$this->log = null;
|
||||
}
|
||||
|
||||
public function assertExecuted(array|string $commands): void
|
||||
{
|
||||
if (! $this->commands) {
|
||||
|
Reference in New Issue
Block a user