class TestFileTransfer in SimpleTest 7
Mock FileTransfer object for test case.
Hierarchy
- class \FileTransfer
- class \TestFileTransfer
Expanded class hierarchy of TestFileTransfer
File
- tests/
filetransfer.test, line 94
View source
class TestFileTransfer extends FileTransfer {
protected $host = NULL;
protected $username = NULL;
protected $password = NULL;
protected $port = NULL;
/**
* This is for testing the CopyRecursive logic.
*/
public $shouldIsDirectoryReturnTrue = FALSE;
function __construct($jail, $username, $password, $hostname = 'localhost', $port = 9999) {
parent::__construct($jail, $username, $password, $hostname, $port);
}
static function factory($jail, $settings) {
return new TestFileTransfer($jail, $settings['username'], $settings['password'], $settings['hostname'], $settings['port']);
}
function connect() {
$parts = explode(':', $this->hostname);
$port = count($parts) == 2 ? $parts[1] : $this->port;
$this->connection = new MockTestConnection();
$this->connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@{$this->host}:{$this->port}/";
}
function copyFileJailed($source, $destination) {
$this->connection
->run("copyFile {$source} {$destination}");
}
protected function removeDirectoryJailed($directory) {
$this->connection
->run("rmdir {$directory}");
}
function createDirectoryJailed($directory) {
$this->connection
->run("mkdir {$directory}");
}
function removeFileJailed($destination) {
if (!ftp_delete($this->connection, $item)) {
throw new FileTransferException('Unable to remove to file @file.', NULL, array(
'@file' => $item,
));
}
}
function isDirectory($path) {
return $this->shouldIsDirectoryReturnTrue;
}
function isFile($path) {
return FALSE;
}
function chmodJailed($path, $mode, $recursive) {
return;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileTransfer:: |
protected | property | ||
FileTransfer:: |
final protected | function | Checks that the path is inside the jail and throws an exception if not. | |
FileTransfer:: |
final public | function | ||
FileTransfer:: |
final public | function | Copies a directory. | |
FileTransfer:: |
protected | function | Copies a directory. | 1 |
FileTransfer:: |
final public | function | Copies a file. | |
FileTransfer:: |
final public | function | Creates a directory. | |
FileTransfer:: |
function | Return the chroot property for this connection. | ||
FileTransfer:: |
final protected | function | Returns a modified path suitable for passing to the server. If a path is a windows path, makes it POSIX compliant by removing the drive letter. If $this->chroot has a value, it is stripped from the path to allow for chroot'd filetransfer systems. | |
FileTransfer:: |
public | function | Returns a form to collect connection settings credentials. | 2 |
FileTransfer:: |
final public | function | Removes a directory. | |
FileTransfer:: |
final public | function | Removes a file. | |
FileTransfer:: |
function | Changes backslashes to slashes, also removes a trailing slash. | ||
FileTransfer:: |
function | Sets the chroot and changes the jail to match the correct path scheme | ||
FileTransfer:: |
function | Implementation of the magic __get() method. | ||
TestFileTransfer:: |
protected | property | ||
TestFileTransfer:: |
protected | property |
Overrides FileTransfer:: |
|
TestFileTransfer:: |
protected | property |
Overrides FileTransfer:: |
|
TestFileTransfer:: |
public | property | This is for testing the CopyRecursive logic. | |
TestFileTransfer:: |
protected | property |
Overrides FileTransfer:: |
|
TestFileTransfer:: |
function | |||
TestFileTransfer:: |
function |
Connect to the server. Overrides FileTransfer:: |
||
TestFileTransfer:: |
function |
Copies a file. Overrides FileTransfer:: |
||
TestFileTransfer:: |
function |
Creates a directory. Overrides FileTransfer:: |
||
TestFileTransfer:: |
static | function |
Classes that extend this class must override the factory() static method. Overrides FileTransfer:: |
|
TestFileTransfer:: |
function |
Checks if a particular path is a directory Overrides FileTransfer:: |
||
TestFileTransfer:: |
function |
Checks if a particular path is a file (not a directory). Overrides FileTransfer:: |
||
TestFileTransfer:: |
protected | function |
Removes a directory. Overrides FileTransfer:: |
|
TestFileTransfer:: |
function |
Removes a file. Overrides FileTransfer:: |
||
TestFileTransfer:: |
function |
The constructor for the UpdateConnection class. This method is also called
from the classes that extend this class and override this method. Overrides FileTransfer:: |