mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-17 18:55:13 +00:00
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Andreas Fischer <bantu@phpbb.com>
|
|
* @copyright 2015 Andreas Fischer
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace phpseclib3\Tests\Functional\Net;
|
|
|
|
use phpseclib3\Net\SFTP;
|
|
use phpseclib3\Tests\PhpseclibFunctionalTestCase;
|
|
|
|
/**
|
|
* This class provides each test method with a new and empty $this->scratchDir.
|
|
*/
|
|
abstract class SFTPTestCase extends PhpseclibFunctionalTestCase
|
|
{
|
|
/**
|
|
* @var SFTP
|
|
*/
|
|
protected $sftp;
|
|
protected $scratchDir;
|
|
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->scratchDir = uniqid('phpseclib-sftp-scratch-');
|
|
|
|
$this->sftp = new SFTP($this->getEnv('SSH_HOSTNAME'));
|
|
$this->assertTrue($this->sftp->login(
|
|
$this->getEnv('SSH_USERNAME'),
|
|
$this->getEnv('SSH_PASSWORD')
|
|
));
|
|
$this->assertTrue($this->sftp->mkdir($this->scratchDir));
|
|
$this->assertTrue($this->sftp->chdir($this->scratchDir));
|
|
}
|
|
|
|
public function tearDown(): void
|
|
{
|
|
if ($this->sftp) {
|
|
$this->sftp->chdir($this->getEnv('SSH_HOME'));
|
|
$this->sftp->delete($this->scratchDir);
|
|
}
|
|
parent::tearDown();
|
|
}
|
|
}
|