You are here

protected function LingotekUtilitiesDisassociateAllDocumentsTest::setUp in Lingotek Translation 8

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides LingotekTestBase::setUp

File

src/Tests/LingotekUtilitiesDisassociateAllDocumentsTest.php, line 37

Class

LingotekUtilitiesDisassociateAllDocumentsTest
Tests disassociating all site documents.

Namespace

Drupal\lingotek\Tests

Code

protected function setUp() {
  parent::setUp();

  // Create Article node types.
  $this
    ->drupalCreateContentType(array(
    'type' => 'article',
    'name' => 'Article',
  ));
  $this->vocabulary = $this
    ->createVocabulary();
  $vocabulary_id = $this->vocabulary
    ->id();

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Enable translation for the articles and our vocabulary and ensure the
  // change is picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'article', TRUE);
  ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vocabulary_id)
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('taxonomy_term', $vocabulary_id, TRUE);
  drupal_static_reset();
  \Drupal::entityManager()
    ->clearCachedDefinitions();
  \Drupal::service('entity.definition_update_manager')
    ->applyUpdates();

  // Rebuild the container so that the new languages are picked up by services
  // that hold a list of languages.
  $this
    ->rebuildContainer();
  $edit = [
    'node[article][enabled]' => 1,
    'node[article][profiles]' => 'manual',
    'node[article][fields][title]' => 1,
    'node[article][fields][body]' => 1,
    "taxonomy_term[{$vocabulary_id}][enabled]" => 1,
    "taxonomy_term[{$vocabulary_id}][profiles]" => 'manual',
    "taxonomy_term[{$vocabulary_id}][fields][name]" => 1,
    "taxonomy_term[{$vocabulary_id}][fields][description]" => 1,
  ];
  $this
    ->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-content-form');
  $edit = [
    'table[node_type][enabled]' => 1,
    'table[node_type][profile]' => 'manual',
  ];
  $this
    ->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-configuration-form');
  $this
    ->translateNodeWithLinks();
  $this
    ->translateTermWithLinks();
  $this
    ->translateSystemSiteConfig();
  $this
    ->translateArticleContentType();
}