You are here

public function LocalTranslatorTest::testAllowAll in Translation Management Tool 8

Test the allow all setting.

File

translators/tmgmt_local/tests/src/Functional/LocalTranslatorTest.php, line 601

Class

LocalTranslatorTest
Basic tests for the local translator.

Namespace

Drupal\Tests\tmgmt_local\Functional

Code

public function testAllowAll() {

  /** @var Translator $translator */
  $translator = Translator::load('local');

  // Create a job and request a local translation.
  $this
    ->loginAsTranslator();
  $job = $this
    ->createJob();
  $job->translator = $translator
    ->id();
  $job
    ->addItem('test_source', 'test', '1');
  $job
    ->addItem('test_source', 'test', '2');
  $this
    ->assertFalse($job
    ->requestTranslation(), 'Translation request was denied.');

  // Now enable the setting.
  $this
    ->config('tmgmt_local.settings')
    ->set('allow_all', TRUE)
    ->save();

  /** @var Job $job */
  $job = \Drupal::entityTypeManager()
    ->getStorage('tmgmt_job')
    ->loadUnchanged($job
    ->id());
  $job->translator = $translator
    ->id();
  $this
    ->assertIdentical(NULL, $job
    ->requestTranslation(), 'Translation request was successfull');
  $this
    ->assertTrue($job
    ->isActive());
}