class TestFileTransfer
Same name in other branches
- 7.x modules/simpletest/tests/filetransfer.test \TestFileTransfer
- 9 core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer
- 8.9.x core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer
- 11.x core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer
Mock FileTransfer object for test case.
Hierarchy
- class \Drupal\Core\FileTransfer\FileTransfer
- class \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer extends \Drupal\Core\FileTransfer\FileTransfer
Expanded class hierarchy of TestFileTransfer
1 file declares its use of TestFileTransfer
- FileTransferTest.php in core/
modules/ system/ tests/ src/ Unit/ FileTransfer/ FileTransferTest.php
File
-
core/
modules/ system/ tests/ src/ Functional/ FileTransfer/ TestFileTransfer.php, line 12
Namespace
Drupal\Tests\system\Functional\FileTransferView source
class TestFileTransfer extends FileTransfer {
/**
* {@inheritdoc}
*/
protected $host = '';
/**
* {@inheritdoc}
*/
protected $username = '';
/**
* {@inheritdoc}
*/
protected $password = '';
/**
* {@inheritdoc}
*/
protected $port = 0;
/**
* This is for testing the CopyRecursive logic.
*
* @var bool
*/
public $shouldIsDirectoryReturnTrue = FALSE;
public static function factory($jail, $settings) {
assert(is_array($settings));
return new TestFileTransfer($jail);
}
public function connect() {
$this->connection = new MockTestConnection();
// Access the connection via the property. The property used to be set via a
// magic method and this can cause problems if coded incorrectly.
$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) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
FileTransfer::$hostname | protected | property | The hostname for this file transfer. | ||
FileTransfer::$jail | protected | property | Full path to directory where file-transfer is restricted to. | ||
FileTransfer::checkPath | final protected | function | Checks that the path is inside the jail and throws an exception if not. | ||
FileTransfer::chmod | final public | function | Changes the permissions of the specified $path (file or directory). | ||
FileTransfer::copyDirectory | final public | function | Copies a directory. | ||
FileTransfer::copyDirectoryJailed | protected | function | Copies a directory. | 1 | |
FileTransfer::copyFile | final public | function | Copies a file. | ||
FileTransfer::createDirectory | final public | function | Creates a directory. | ||
FileTransfer::findChroot | public | function | Returns the chroot property for this connection. | ||
FileTransfer::fixRemotePath | final protected | function | Returns a modified path suitable for passing to the server. | ||
FileTransfer::getSettingsForm | public | function | Returns a form to collect connection settings credentials. | 3 | |
FileTransfer::removeDirectory | final public | function | Removes a directory. | ||
FileTransfer::removeFile | final public | function | Removes a file. | ||
FileTransfer::sanitizePath | public | function | Changes backslashes to slashes, also removes a trailing slash. | ||
FileTransfer::setChroot | public | function | Sets the chroot and changes the jail to match the correct path scheme. | ||
FileTransfer::__construct | public | function | Constructs a Drupal\Core\FileTransfer\FileTransfer object. | 3 | |
FileTransfer::__get | public | function | Implements the magic __get() method. | ||
FileTransfer::__isset | public | function | |||
FileTransfer::__set | public | function | |||
FileTransfer::__unset | public | function | |||
TestFileTransfer::$host | protected | property | |||
TestFileTransfer::$password | protected | property | The password for this file transfer. | Overrides FileTransfer::$password | |
TestFileTransfer::$port | protected | property | The port for this file transfer. | Overrides FileTransfer::$port | |
TestFileTransfer::$shouldIsDirectoryReturnTrue | public | property | This is for testing the CopyRecursive logic. | ||
TestFileTransfer::$username | protected | property | The username for this file transfer. | Overrides FileTransfer::$username | |
TestFileTransfer::chmodJailed | public | function | |||
TestFileTransfer::connect | public | function | Connects to the server. | Overrides FileTransfer::connect | |
TestFileTransfer::copyFileJailed | public | function | Copies a file. | Overrides FileTransfer::copyFileJailed | |
TestFileTransfer::createDirectoryJailed | public | function | Creates a directory. | Overrides FileTransfer::createDirectoryJailed | |
TestFileTransfer::factory | public static | function | Defines a factory method for this class. | Overrides FileTransfer::factory | |
TestFileTransfer::isDirectory | public | function | Checks if a particular path is a directory. | Overrides FileTransfer::isDirectory | |
TestFileTransfer::isFile | public | function | Checks if a particular path is a file (not a directory). | Overrides FileTransfer::isFile | |
TestFileTransfer::removeDirectoryJailed | protected | function | Removes a directory. | Overrides FileTransfer::removeDirectoryJailed | |
TestFileTransfer::removeFileJailed | public | function | Removes a file. | Overrides FileTransfer::removeFileJailed |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.