1 filetransfer.test FileTranferTest::testJail()

File

core/modules/simpletest/tests/filetransfer.test, line 58

Class

FileTranferTest

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, '/tmp');
  }
  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, BACKDROP_ROOT . '/' . config_get('system.core', 'file_public_path'));
  }
  catch (FileTransferException $e) {
    $gotit = FALSE;
  }
  $this->assertTrue($gotit, 'Was able to copy a directory inside of the jailed area');
}