You are here

public function LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  2. 4.0.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  3. 3.0.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  4. 3.1.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  5. 3.2.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  6. 3.3.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  7. 3.5.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  8. 3.6.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  9. 3.7.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()
  10. 3.8.x tests/src/Functional/LingotekFieldBodyTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldBodyTranslationTest::testUploadingWithAPaymentRequiredErrorViaAutomaticUpload()

Test that we handle errors in upload.

File

tests/src/Functional/LingotekFieldBodyTranslationTest.php, line 641

Class

LingotekFieldBodyTranslationTest
Tests translating a field.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testUploadingWithAPaymentRequiredErrorViaAutomaticUpload() {
  \Drupal::state()
    ->set('lingotek.must_payment_required_error_in_upload', TRUE);
  $this
    ->drupalGet('admin/lingotek/settings');

  // Create a field.
  $edit = [
    'label' => 'Excerpt',
    'new_storage_type' => 'text',
    'field_name' => 'excerpt',
  ];
  $this
    ->drupalPostForm('/admin/structure/types/manage/article/fields/add-field', $edit, 'Save and continue');

  // The document was uploaded automatically and failed.
  $this
    ->assertText('Community has been disabled. Please contact support@lingotek.com to re-enable your community.');

  // The field has been marked with the error status.
  $fieldConfig = FieldConfig::load('node.article.field_excerpt');

  /** @var \Drupal\lingotek\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.');
}