public function LingotekFieldBodyTranslationTest::testUploadingWithAnError in Lingotek Translation 8
Test that we handle errors in upload.
File
- src/
Tests/ LingotekFieldBodyTranslationTest.php, line 207
Class
- LingotekFieldBodyTranslationTest
- Tests translating a field.
Namespace
Drupal\lingotek\TestsCode
public function testUploadingWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
// Check that the translate tab is in the field.
$this
->drupalGet('/admin/config/regional/config-translation/node_fields');
$this
->clickLink(t('Translate'));
// Upload the document, which must fail.
$this
->clickLink('Upload');
$this
->assertText('Body upload failed. Please try again.');
// The field has been marked with the error status.
$fieldConfig = FieldConfig::load('node.article.body');
/** @var LingotekConfigTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.config_translation');
$source_status = $translation_service
->getSourceStatus($fieldConfig);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The field has been marked as error.');
// I can still re-try the upload.
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('Upload');
$this
->assertText('Body uploaded successfully');
}