@devhobby Can you be explicit about errors?
What is the error exactly?
Summer Sale! All accounts are 50% off this week.
Hi all.
I am using Storage for SFTP connection. Now I want to close the connection after connecting it every time. For example, this is my getFiles() method from a class.
$connection = Storage::disk('sftp');
$files = $connection->get('some-directory');
$connection->getDriver()->getAdapter()->disconnect();
Everything is working fine.
But my test fails for this behavior. This is my test.
public function test_get_all_files_from_ftp()
{
Storage::fake('sftp');
// Act
$files = (new FtpConnector())->getFiles('some-directory');
// Assert
$this->assertEquals(x, count($files));
}
Thanks in advanced.
@devhobby It's because you are faking sftp (Storage::fake('sftp');) which under the hood use the local driver. Therefore you are getting this error.
You can use this:
$adapter = $connection->getDriver()->getAdapter();
if (method_exists($adapter, 'disconnect')) {
$adapter->disconnect();
}
Please or to participate in this conversation.