function FileTranslatorTest::testPrivate in Translation Management Tool 8
Tests storing files in the private file system.
File
- translators/
tmgmt_file/ tests/ src/ Functional/ FileTranslatorTest.php, line 460
Class
- FileTranslatorTest
- Tests for the file translator.
Namespace
Drupal\Tests\tmgmt_file\FunctionalCode
function testPrivate() {
// Create a translator using the private file system.
// @todo: Test the configuration UI.
$translator = $this
->createTranslator([
'plugin' => 'file',
'settings' => [
'export_format' => 'xlf',
'xliff_processing' => TRUE,
'scheme' => 'private',
],
]);
$job = $this
->createJob();
$job->translator = $translator
->id();
$job
->addItem('test_source', 'test', '1');
$job
->addItem('test_source', 'test', '2');
$job
->requestTranslation();
$messages = $job
->getMessages();
$message = reset($messages);
$this
->drupalGet('admin/tmgmt/jobs');
$this
->clickLink(t('Manage'));
// Assert that the label field is only shown once in page.
$this
->assertEqual(count($this
->xpath('//div[@id="tmgmt-ui-label"]')), 1);
$download_url = $message->variables->{'@link'};
$this
->assertFalse((bool) strpos('< a', $download_url));
$this
->drupalGet($download_url);
// Verify that the URL is served using the private file system and the
// access checks work.
$this
->assertNotEmpty(preg_match('|system/files|', $download_url));
$this
->assertResponse(200);
$this
->drupalLogout();
// Verify that access is now protected.
$this
->drupalGet($download_url);
$this
->assertResponse(403);
}