You are here

function FileTransferTest::testJail in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/FileTransfer/FileTransferTest.php \Drupal\system\Tests\FileTransfer\FileTransferTest::testJail()

File

core/modules/system/src/Tests/FileTransfer/FileTransferTest.php, line 74
Contains \Drupal\system\Tests\FileTransfer\FileTransferTest.

Class

FileTransferTest
Tests that the jail is respected and that protocols using recursive file move operations work.

Namespace

Drupal\system\Tests\FileTransfer

Code

function testJail() {
  $source = $this
    ->_buildFakeModule();

  // This convoluted piece of code is here because our testing framework does
  // not support expecting exceptions.
  $gotit = FALSE;
  try {
    $this->testConnection
      ->copyDirectory($source, sys_get_temp_dir());
  } catch (FileTransferException $e) {
    $gotit = TRUE;
  }
  $this
    ->assertTrue($gotit, 'Was not able to copy a directory outside of the jailed area.');
  $gotit = TRUE;
  try {
    $this->testConnection
      ->copyDirectory($source, \Drupal::root() . '/' . PublicStream::basePath());
  } catch (FileTransferException $e) {
    $gotit = FALSE;
  }
  $this
    ->assertTrue($gotit, 'Was able to copy a directory inside of the jailed area');
}