public function LingotekProfileFormTest::testProfileSettingsOverride in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 4.0.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.0.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.1.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.2.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.3.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.4.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.5.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.6.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
- 3.7.x tests/src/Functional/Form/LingotekProfileFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekProfileFormTest::testProfileSettingsOverride()
Test profiles language settings override.
File
- tests/
src/ Functional/ Form/ LingotekProfileFormTest.php, line 394
Class
- LingotekProfileFormTest
- Tests the Lingotek profile form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testProfileSettingsOverride() {
$assert_session = $this
->assertSession();
// Add a language.
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
ConfigurableLanguage::createFromLangcode('de')
->setThirdPartySetting('lingotek', 'locale', 'de_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");
$assert_session
->optionExists('edit-language-overrides-es-overrides', 'default');
$assert_session
->optionExists('edit-language-overrides-en-overrides', 'default');
$edit = [
'auto_upload' => FALSE,
'auto_download' => 1,
'project' => 'default',
'vault' => 'default',
'workflow' => 'test_workflow2',
'language_overrides[es][overrides]' => 'custom',
'language_overrides[es][custom][auto_download]' => FALSE,
'language_overrides[es][custom][workflow]' => 'test_workflow',
'language_overrides[es][custom][vault]' => 'test_vault',
'language_overrides[de][overrides]' => 'custom',
'language_overrides[de][custom][auto_download]' => FALSE,
'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('test_workflow', $profile
->getWorkflowForTarget('es'));
$this
->assertIdentical('default', $profile
->getWorkflowForTarget('de'));
$this
->assertIdentical('test_vault', $profile
->getVaultForTarget('es'));
$this
->assertIdentical('default', $profile
->getVaultForTarget('de'));
$this
->assertFalse($profile
->hasAutomaticDownloadForTarget('es'));
$this
->assertFalse($profile
->hasAutomaticDownloadForTarget('de'));
$this
->drupalGet("/admin/lingotek/settings/profile/{$profile_id}/edit");
$this
->assertNoFieldChecked("edit-auto-upload");
$this
->assertFieldChecked("edit-auto-download");
$assert_session
->optionExists('edit-project', 'default');
$assert_session
->optionExists('edit-vault', 'default');
$assert_session
->optionExists('edit-workflow', 'test_workflow2');
$assert_session
->optionExists('edit-language-overrides-es-overrides', 'custom');
$assert_session
->optionExists('edit-language-overrides-de-overrides', 'custom');
$assert_session
->optionExists('edit-language-overrides-en-overrides', 'default');
$this
->assertNoFieldChecked('edit-language-overrides-es-custom-auto-download');
$this
->assertNoFieldChecked('edit-language-overrides-de-custom-auto-download');
$this
->assertFieldChecked('edit-language-overrides-en-custom-auto-download');
$assert_session
->optionExists('edit-language-overrides-es-custom-workflow', 'test_workflow');
$assert_session
->optionExists('edit-language-overrides-de-custom-workflow', 'default');
$assert_session
->optionExists('edit-language-overrides-en-custom-workflow', 'default');
// Assert that the override languages are present and ordered alphabetically.
$selects = $this
->xpath('//details[@id="edit-language-overrides"]/*/*//select');
// There must be 2 select options for each of the 3 languages.
$this
->assertEqual(count($selects), 3 * 3, 'There are options for all the potential language overrides.');
// And the first one must be German alphabetically.
$this
->assertEqual($selects[0]
->getAttribute('id'), 'edit-language-overrides-de-overrides', 'Languages are ordered alphabetically.');
}