You are here

class TestFileTransfer in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer
  2. 9 core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php \Drupal\Tests\system\Functional\FileTransfer\TestFileTransfer

Mock FileTransfer object for test case.

Hierarchy

Expanded class hierarchy of TestFileTransfer

1 string reference to 'TestFileTransfer'
drupal7.php in core/modules/migrate_drupal/tests/fixtures/drupal7.php
A database agnostic dump for testing purposes.

File

core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php, line 10

Namespace

Drupal\Tests\system\Functional\FileTransfer
View 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 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) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileTransfer::$hostname protected property The hostname for this file transfer.
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.
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. 1
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::__get public function Implements the magic __get() method.
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
TestFileTransfer::__construct public function Constructs a Drupal\Core\FileTransfer\FileTransfer object. Overrides FileTransfer::__construct