You are here

public function LingotekSettingsTabContentFormTest::testContentTypesAreNotDisabledIfThereAreLotsOfContentTypes in Lingotek Translation 3.6.x

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

File

tests/src/Functional/Form/LingotekSettingsTabContentFormTest.php, line 767

Class

LingotekSettingsTabContentFormTest
Tests the Lingotek content settings form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testContentTypesAreNotDisabledIfThereAreLotsOfContentTypes() {

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

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $this
    ->saveLingotekContentTranslationSettingsForNodeTypes();
  foreach (range(1, 150) as $i) {
    $this
      ->drupalCreateContentType([
      'type' => 'content_type_' . $i,
      'name' => 'Content Type ' . $i,
    ]);
    ContentLanguageSettings::loadByEntityTypeBundle('node', 'content_type_' . $i)
      ->setLanguageAlterable(TRUE)
      ->save();
    \Drupal::service('content_translation.manager')
      ->setEnabled('node', 'content_type_' . $i, TRUE);
  }

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

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $this
    ->drupalGet('admin/lingotek/settings');

  // Check the form contains the fields, and have the proper values,
  // but they are disabled.
  $this
    ->assertFieldChecked('edit-node-article-readonly-enabled');
  $this
    ->assertFieldByName('node[article][profiles]', 'automatic');
  $edit = [
    'node[article][profiles]' => 'manual',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save', [], 'lingoteksettings-tab-content-form');

  // Check the form contains the fields, and have the proper values,
  // but they are disabled.
  $this
    ->assertFieldChecked('edit-node-article-readonly-enabled');
  $this
    ->assertFieldByName('node[article][profiles]', 'manual');
}