Fix SFTP Mock

This commit is contained in:
philipp lang 2026-04-23 15:37:11 +02:00
parent ca5d5e157b
commit 8c625180ab
1 changed files with 10 additions and 0 deletions

View File

@ -57,6 +57,7 @@ class FilesystemConfig
{
if (!app()->has('original-filesystem')) {
app()->singleton('original-filesystem', fn () => app(FilesystemManager::class));
app('original-filesystem');
$mock = M::mock(FilesystemManager::class)->makePartial();
app()->instance(FilesystemManager::class, $mock);
}
@ -68,6 +69,15 @@ class FilesystemConfig
->andReturnUsing(function () {
return app('original-filesystem')->createLocalDriver(['root' => __DIR__ . '/fakes/' . $this->identifier]);
});
$mock->shouldReceive('createSftpDriver')->withArgs(fn ($config) => $this->host === $config['host'] && $this->username === $config['username'] && $this->password === $config['password'] && $this->path === $config['root'])
->andReturnUsing(function () {
return new class {
public function files(string $path)
{
throw new \Exception('SFTP not supported in tests');
}
};
});
return app('original-filesystem')->createLocalDriver(['root' => __DIR__ . '/fakes/' . $this->identifier]);
}