You are here

public function LingotekContentTypeTranslationTest::testContentTypeTranslation in Lingotek Translation 4.0.x

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

Tests that a node can be translated.

1 call to LingotekContentTypeTranslationTest::testContentTypeTranslation()
LingotekContentTypeTranslationTest::testEditedContentTypeTranslation in tests/src/Functional/LingotekContentTypeTranslationTest.php
Tests that a config can be translated after edited.

File

tests/src/Functional/LingotekContentTypeTranslationTest.php, line 52

Class

LingotekContentTypeTranslationTest
Tests translating a content type.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testContentTypeTranslation() {
  $assert_session = $this
    ->assertSession();

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'content_type');

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet('/admin/config/regional/config-translation');
  $this
    ->drupalGet('/admin/config/regional/config-translation/node_type');
  $this
    ->clickLink(t('Translate'));
  $this
    ->clickLink(t('Upload'));
  $this
    ->assertText(t('Article uploaded successfully'));

  // Check that only the translatable fields have been uploaded.
  $data = json_decode(\Drupal::state()
    ->get('lingotek.uploaded_content', '[]'), TRUE);
  $this
    ->assertEqual(3, count($data));
  $this
    ->assertTrue(array_key_exists('name', $data));

  // Cannot use isset, the key exists but we are not providing values, so NULL.
  $this
    ->assertTrue(array_key_exists('description', $data));
  $this
    ->assertTrue(array_key_exists('help', $data));

  // Check that the profile used was the right one.
  $used_profile = \Drupal::state()
    ->get('lingotek.used_profile');
  $this
    ->assertIdentical('automatic', $used_profile, 'The automatic profile was used.');
  $this
    ->clickLink(t('Check upload status'));
  $this
    ->assertText(t('Article status checked successfully'));
  $this
    ->clickLink(t('Request translation'));
  $this
    ->assertText(t('Translation to es_MX requested successfully'));
  $this
    ->assertIdentical('es_MX', \Drupal::state()
    ->get('lingotek.added_target_locale'));
  $this
    ->clickLink(t('Check Download'));
  $this
    ->assertText(t('Translation to es_MX status checked successfully'));
  $this
    ->clickLink('Download');
  $this
    ->assertText(t('Translation to es_MX downloaded successfully'));

  // Check that the edit link is there.
  $basepath = \Drupal::request()
    ->getBasePath();
  $assert_session
    ->linkByHrefExists($basepath . '/admin/structure/types/manage/article/translate/es/edit');
}