You are here

function TMGMTFileTestCase::testPrivate in Translation Management Tool 7

Tests storing files in the private file system.

File

translators/file/tmgmt_file.test, line 412
Test cases for the file translator module.

Class

TMGMTFileTestCase
Basic tests for the file translator.

Code

function testPrivate() {

  // Enable the private file system.
  variable_set('file_private_path', variable_get('file_public_path') . '/private');

  // Create a translator using the private file system.
  // @todo: Test the configuration UI.
  $translator = $this
    ->createTranslator();
  $translator->plugin = 'file';
  $translator->settings = array(
    'export_format' => 'xlf',
    'scheme' => 'private',
  );
  $translator
    ->save();
  $job = $this
    ->createJob();
  $job->translator = $translator->name;
  $job
    ->addItem('test_source', 'test', '1');
  $job
    ->addItem('test_source', 'test', '2');
  $job
    ->requestTranslation();
  $messages = $job
    ->getMessages();
  $message = reset($messages);
  $download_url = $message->variables['!link'];
  $this
    ->drupalGet($download_url);

  // Verify that the URL is served using the private file system and the
  // access checks work.
  $this
    ->assertTrue(preg_match('|system/files|', $download_url));
  $this
    ->assertResponse(200);
  $this
    ->drupalLogout();

  // Verify that access is now protected.
  $this
    ->drupalGet($download_url);
  $this
    ->assertResponse(403);
}