public function LingotekSystemSiteBulkTranslationTest::testUploadingWithAnErrorUsingActions in Lingotek Translation 8
Test that we handle errors in upload.
File
- src/
Tests/ LingotekSystemSiteBulkTranslationTest.php, line 371
Class
- LingotekSystemSiteBulkTranslationTest
- Tests translating a config object using the bulk management form.
Namespace
Drupal\lingotek\TestsCode
public function testUploadingWithAnErrorUsingActions() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$this
->goToConfigBulkManagementForm();
// Upload the document, which must fail.
$basepath = \Drupal::request()
->getBasePath();
$this
->assertLinkByHref($basepath . '/admin/lingotek/config/upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
$edit = [
'table[system.site_information_settings]' => TRUE,
// System information.
'operation' => 'upload',
];
$this
->drupalPostForm(NULL, $edit, t('Execute'));
$this
->assertText('System information upload failed. Please try again.');
// Check the right class is added.
$source_error = $this
->xpath("//span[contains(@class,'language-icon') and contains(@class,'source-error') and ./a[contains(text(), 'EN')]]");
$this
->assertEqual(count($source_error), 1, 'The system information has been marked as error.');
// The config mapper has been marked with the error status.
/** @var ConfigMapperManagerInterface $mapperManager */
$mapperManager = \Drupal::service('plugin.manager.config_translation.mapper');
$mapper = $mapperManager
->getMappers()['system.site_information_settings'];
/** @var LingotekConfigTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.config_translation');
$source_status = $translation_service
->getConfigSourceStatus($mapper);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The system information has been marked as error.');
// I can still re-try the upload.
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN', 1);
$this
->assertText(t('System information uploaded successfully'));
}