You are here

public function LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  2. 3.2.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  3. 3.3.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  4. 3.5.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  5. 3.6.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  6. 3.7.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()
  7. 3.8.x tests/src/Functional/LingotekNodeManageTranslationTabTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeManageTranslationTabTest::testNodeTranslationMessageWhenBundleNotConfigured()

Tests that a node cannot be translated if not configured, and will provide user-friendly messages.

File

tests/src/Functional/LingotekNodeManageTranslationTabTest.php, line 261

Class

LingotekNodeManageTranslationTabTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

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

  // Create Article node types.
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Page',
  ]);

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'page')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'page', TRUE);

  // Create a node.
  $edit = [];
  $edit['title[0][value]'] = 'Pages are cool';
  $edit['body[0][value]'] = 'Pages are very cool';
  $edit['langcode[0][value]'] = 'en';
  $this
    ->drupalPostForm('node/add/page', $edit, t('Save'));

  // Check that the manage translations tab is in the node.
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('Manage Translations');
  $assert_session
    ->pageTextContains('Not enabled');
  $this
    ->clickLink('EN');
  $assert_session
    ->pageTextContains('Cannot upload Page Pages are cool. That Content type is not enabled for Lingotek translation.');
  $edit = [
    'table[node:1]' => TRUE,
    $this
      ->getBulkOperationFormName() => $this
      ->getBulkOperationNameForUpload('node'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, $this
    ->getApplyActionsButtonLabel());
  $this
    ->assertIdentical(NULL, \Drupal::state()
    ->get('lingotek.uploaded_locale'));
  $assert_session
    ->pageTextContains('Cannot upload Page Pages are cool. That Content type is not enabled for Lingotek translation.');
}