public function LingotekInterfaceTranslationTest::testUploadingWithAnError in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.2.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.3.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.4.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.5.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.7.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
- 3.8.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testUploadingWithAnError()
Test that we handle errors in upload.
File
- tests/
src/ Functional/ LingotekInterfaceTranslationTest.php, line 316
Class
- LingotekInterfaceTranslationTest
- Tests translating the user interface using the Lingotek form.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testUploadingWithAnError() {
\Drupal::state()
->set('lingotek.must_error_in_upload', TRUE);
// In Drupal.org CI the module will be at modules/contrib/lingotek.
// In my local that's modules/lingotek. We need to generate the path and not
// hardcode it.
$path = drupal_get_path('module', 'lingotek_interface_translation_test');
$component = $path;
$indexOfModuleLink = 2;
$assert_session = $this
->assertSession();
// Login as admin.
$this
->drupalLogin($this->rootUser);
$this
->goToInterfaceTranslationManagementForm();
$assert_session
->responseContains('lingotek_interface_translation_test');
// Clicking English must init the upload of content.
$this
->assertLingotekInterfaceTranslationUploadLink($component);
// Upload the document, which must fail.
$this
->clickLink('EN', $indexOfModuleLink);
$assert_session
->responseContains('The upload for <em class="placeholder">' . $component . '</em> failed. Please try again.');
// Check the right class is added.
$this
->assertSourceStatus('EN', Lingotek::STATUS_ERROR);
/** @var \Drupal\lingotek\LingotekInterfaceTranslationServiceInterface $translation_service */
$translation_service = \Drupal::service('lingotek.interface_translation');
$source_status = $translation_service
->getSourceStatus($component);
$this
->assertEqual(Lingotek::STATUS_ERROR, $source_status, 'The source upload has been marked as error.');
$this
->assertEmpty($translation_service
->getLastUploaded($component));
// I can still re-try the upload.
\Drupal::state()
->set('lingotek.must_error_in_upload', FALSE);
$this
->clickLink('EN', $indexOfModuleLink);
$assert_session
->responseContains('<em class="placeholder">' . $component . '</em> uploaded successfully');
drupal_flush_all_caches();
$expected_time = \Drupal::time()
->getRequestTime();
$this
->assertEquals($expected_time, $translation_service
->getLastUploaded($component));
}