public function LingotekContentTypeTranslationTest::testUploadingWithAnErrorViaAPI in Lingotek Translation 8
Test that we handle errors in upload.
File
- src/
Tests/ LingotekContentTypeTranslationTest.php, line 272
Class
- LingotekContentTypeTranslationTest
- Tests translating a content type.
Namespace
Drupal\lingotek\TestsCode
public function testUploadingWithAnErrorViaAPI() {
$edit = [
'table[node_type][enabled]' => 1,
'table[node_type][profile]' => 'automatic',
];
$this
->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-configuration-form');
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
$this
->drupalGet('admin/lingotek/settings');
// Create a content type.
$edit = [
'name' => 'Landing Page',
'type' => 'landing_page',
];
$this
->drupalPostForm('admin/structure/types/add', $edit, 'Save content type');
// The document was uploaded automatically and failed.
$this
->assertText('The upload for node_type Landing Page failed. Please try again.');
// The node type has been marked with the error status.
$nodeType = NodeType::load('landing_page');
/** @var LingotekConfigTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.config_translation');
$source_status = $translation_service
->getSourceStatus($nodeType);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The node type has been marked as error.');
}