You are here

class TestFileTransfer in Drupal 7

Mock FileTransfer object for test case.

Hierarchy

Expanded class hierarchy of TestFileTransfer

File

modules/simpletest/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

Namesort descending Modifiers Type Description Overrides
FileTransfer::$hostname protected property
FileTransfer::checkPath final protected function Checks that the path is inside the jail and throws an exception if not.
FileTransfer::chmod final public function
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 function Return the chroot property for this connection.
FileTransfer::fixRemotePath 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::getSettingsForm public function Returns a form to collect connection settings credentials. 2
FileTransfer::removeDirectory final public function Removes a directory.
FileTransfer::removeFile final public function Removes a file.
FileTransfer::sanitizePath function Changes backslashes to slashes, also removes a trailing slash.
FileTransfer::setChroot function Sets the chroot and changes the jail to match the correct path scheme
FileTransfer::__get function Implementation of the magic __get() method.
TestFileTransfer::$host protected property
TestFileTransfer::$password protected property Overrides FileTransfer::$password
TestFileTransfer::$port protected property Overrides FileTransfer::$port
TestFileTransfer::$shouldIsDirectoryReturnTrue public property This is for testing the CopyRecursive logic.
TestFileTransfer::$username protected property Overrides FileTransfer::$username
TestFileTransfer::chmodJailed function
TestFileTransfer::connect function Connect to the server. Overrides FileTransfer::connect
TestFileTransfer::copyFileJailed function Copies a file. Overrides FileTransfer::copyFileJailed
TestFileTransfer::createDirectoryJailed function Creates a directory. Overrides FileTransfer::createDirectoryJailed
TestFileTransfer::factory static function Classes that extend this class must override the factory() static method. Overrides FileTransfer::factory
TestFileTransfer::isDirectory function Checks if a particular path is a directory Overrides FileTransfer::isDirectory
TestFileTransfer::isFile 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 function Removes a file. Overrides FileTransfer::removeFileJailed
TestFileTransfer::__construct 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::__construct