You are here

public function LingotekProfileFormTest::testProfileTargetOverrideAsDisabled in Lingotek Translation 3.5.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileTargetOverrideAsDisabled()
  2. 3.6.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileTargetOverrideAsDisabled()
  3. 3.7.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileTargetOverrideAsDisabled()
  4. 3.8.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileTargetOverrideAsDisabled()

Tests that a profile target can be set as disabled.

File

tests/src/Functional/Form/LingotekProfileFormTest.php, line 471

Class

LingotekProfileFormTest
Tests the Lingotek profile form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testProfileTargetOverrideAsDisabled() {

  // Add a language.
  $es = ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX');
  $de = ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_DE');
  $es
    ->save();
  $de
    ->save();

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::create([
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $profile
    ->save();
  $profile_id = $profile
    ->id();
  $this
    ->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
  $edit = [
    'auto_upload' => FALSE,
    'auto_download' => 1,
    'project' => 'default',
    'vault' => 'default',
    'workflow' => 'test_workflow2',
    'language_overrides[es][overrides]' => 'disabled',
    'language_overrides[de][overrides]' => 'custom',
    'language_overrides[de][custom][auto_request]' => TRUE,
    'language_overrides[de][custom][auto_download]' => TRUE,
    'language_overrides[de][custom][workflow]' => 'default',
    'language_overrides[de][custom][vault]' => 'default',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  /** @var \Drupal\lingotek\LingotekProfileInterface $profile */
  $profile = LingotekProfile::load($profile_id);
  $this
    ->assertFalse($profile
    ->hasAutomaticUpload());
  $this
    ->assertTrue($profile
    ->hasAutomaticDownload());
  $this
    ->assertIdentical('default', $profile
    ->getProject());
  $this
    ->assertIdentical('default', $profile
    ->getVault());
  $this
    ->assertIdentical('test_workflow2', $profile
    ->getWorkflow());
  $this
    ->assertIdentical(NULL, $profile
    ->getWorkflowForTarget('es'));
  $this
    ->assertIdentical(NULL, $profile
    ->getVaultForTarget('es'));
  $this
    ->assertTrue($profile
    ->hasDisabledTarget('es'));
  $this
    ->assertFalse($profile
    ->hasAutomaticRequestForTarget('es'));
  $this
    ->assertTrue($profile
    ->hasAutomaticRequestForTarget('de'));
  $this
    ->assertFalse($profile
    ->hasAutomaticDownloadForTarget('es'));
  $this
    ->assertTrue($profile
    ->hasAutomaticDownloadForTarget('de'));
}