TestFileTransfer.php in Drupal 10
File
core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
View source
<?php
namespace Drupal\Tests\system\Functional\FileTransfer;
use Drupal\Core\FileTransfer\FileTransfer;
class TestFileTransfer extends FileTransfer {
protected $host = '';
protected $username = '';
protected $password = '';
protected $port = 0;
public $shouldIsDirectoryReturnTrue = FALSE;
public function __construct($jail, $username, $password, $hostname = 'localhost', $port = 9999) {
parent::__construct($jail, $username, $password, $hostname, $port);
}
public static function factory($jail, $settings) {
return new TestFileTransfer($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
}
public function connect() {
$this->connection = new MockTestConnection();
$this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@{$this->host}:{$this->port}/";
}
public function copyFileJailed($source, $destination) {
$this->connection
->run("copyFile {$source} {$destination}");
}
protected function removeDirectoryJailed($directory) {
$this->connection
->run("rmdir {$directory}");
}
public function createDirectoryJailed($directory) {
$this->connection
->run("mkdir {$directory}");
}
public function removeFileJailed($destination) {
$this->connection
->run("rm {$destination}");
}
public function isDirectory($path) {
return $this->shouldIsDirectoryReturnTrue;
}
public function isFile($path) {
return FALSE;
}
public function chmodJailed($path, $mode, $recursive) {
}
}