You are here

public function LingotekNodeTranslationTest::testNodeTranslationMessageWhenBundleNotConfigured in Lingotek Translation 3.6.x

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

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

File

tests/src/Functional/LingotekNodeTranslationTest.php, line 184

Class

LingotekNodeTranslationTest
Tests translating a node.

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 translate tab is in the node.
  $this
    ->drupalGet('node/1');
  $this
    ->clickLink('Translate');
  $this
    ->clickLink('Upload');
  $this
    ->checkForMetaRefresh();
  $assert_session
    ->pageTextContains('Cannot upload Page Pages are cool. That Content type is not enabled for Lingotek translation.');
  $assert_session
    ->pageTextContains('Uploaded 0 documents to Lingotek.');
}