2015-06-24 22:15:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Andreas Fischer <bantu@phpbb.com>
|
|
|
|
* @copyright 2015 Andreas Fischer
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
*/
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-02-23 02:48:51 +00:00
|
|
|
namespace phpseclib3\Tests\Functional\Net;
|
|
|
|
|
2019-11-07 05:41:40 +00:00
|
|
|
use phpseclib3\Net\SFTP;
|
2022-02-23 02:48:51 +00:00
|
|
|
use phpseclib3\Tests\PhpseclibFunctionalTestCase;
|
2015-07-03 23:18:19 +00:00
|
|
|
|
2015-06-24 22:15:19 +00:00
|
|
|
/**
|
|
|
|
* This class provides each test method with a new and empty $this->scratchDir.
|
|
|
|
*/
|
2022-02-23 02:48:51 +00:00
|
|
|
abstract class SFTPTestCase extends PhpseclibFunctionalTestCase
|
2015-06-24 22:15:19 +00:00
|
|
|
{
|
2016-04-30 21:23:35 +00:00
|
|
|
/**
|
|
|
|
* @var SFTP
|
|
|
|
*/
|
2015-06-24 22:15:19 +00:00
|
|
|
protected $sftp;
|
|
|
|
protected $scratchDir;
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
public function setUp(): void
|
2015-06-24 22:15:19 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->scratchDir = uniqid('phpseclib-sftp-scratch-');
|
|
|
|
|
2015-07-03 23:18:19 +00:00
|
|
|
$this->sftp = new SFTP($this->getEnv('SSH_HOSTNAME'));
|
2015-06-24 22:15:19 +00:00
|
|
|
$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));
|
|
|
|
}
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
public function tearDown(): void
|
2015-06-24 22:15:19 +00:00
|
|
|
{
|
|
|
|
if ($this->sftp) {
|
|
|
|
$this->sftp->chdir($this->getEnv('SSH_HOME'));
|
|
|
|
$this->sftp->delete($this->scratchDir);
|
|
|
|
}
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
}
|