public function LingotekSystemSiteBulkTranslationTest::testUploadingWithAnError in Lingotek Translation 8
Test that we handle errors in upload.
File
- src/
Tests/ LingotekSystemSiteBulkTranslationTest.php, line 296
Class
- LingotekSystemSiteBulkTranslationTest
- Tests translating a config object using the bulk management form.
Namespace
Drupal\lingotek\TestsCode
public function testUploadingWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$this
->goToConfigBulkManagementForm();
// Upload the document, which must fail.
$this
->clickLink('EN', 1);
$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'));
}