You are here

public function LingotekNodeBulkTranslationTest::testNodeTranslationMessageWhenBundleNotConfiguredWithActions in Lingotek Translation 4.0.x

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

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

File

tests/src/Functional/LingotekNodeBulkTranslationTest.php, line 158

Class

LingotekNodeBulkTranslationTest
Tests translating a node using the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testNodeTranslationMessageWhenBundleNotConfiguredWithActions() {
  $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'));
  $this
    ->goToContentBulkManagementForm();
  $key = $this
    ->getBulkSelectionKey('en', 1);
  $edit = [
    $key => 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.');
}