Fix SFTP Mock
This commit is contained in:
parent
ca5d5e157b
commit
8c625180ab
|
|
@ -57,6 +57,7 @@ class FilesystemConfig
|
||||||
{
|
{
|
||||||
if (!app()->has('original-filesystem')) {
|
if (!app()->has('original-filesystem')) {
|
||||||
app()->singleton('original-filesystem', fn () => app(FilesystemManager::class));
|
app()->singleton('original-filesystem', fn () => app(FilesystemManager::class));
|
||||||
|
app('original-filesystem');
|
||||||
$mock = M::mock(FilesystemManager::class)->makePartial();
|
$mock = M::mock(FilesystemManager::class)->makePartial();
|
||||||
app()->instance(FilesystemManager::class, $mock);
|
app()->instance(FilesystemManager::class, $mock);
|
||||||
}
|
}
|
||||||
|
|
@ -68,6 +69,15 @@ class FilesystemConfig
|
||||||
->andReturnUsing(function () {
|
->andReturnUsing(function () {
|
||||||
return app('original-filesystem')->createLocalDriver(['root' => __DIR__ . '/fakes/' . $this->identifier]);
|
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]);
|
return app('original-filesystem')->createLocalDriver(['root' => __DIR__ . '/fakes/' . $this->identifier]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue