You are here

protected function LingotekContentTranslationDocumentUploadHookTest::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/LingotekContentTranslationDocumentUploadHookTest.php, line 30

Class

LingotekContentTranslationDocumentUploadHookTest
Tests the hooks a node.

Namespace

Drupal\lingotek\Tests

Code

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

  // Place the actions and title block.
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('page_title_block');

  // Create node types.
  $this
    ->drupalCreateContentType(array(
    'type' => 'animal',
    'name' => 'Animal',
  ));
  $this
    ->createImageField('field_image', 'animal');

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX')
    ->save();

  // Enable translation for the current entity type and ensure the change is
  // picked up.
  ContentLanguageSettings::loadByEntityTypeBundle('node', 'animal')
    ->setLanguageAlterable(TRUE)
    ->save();
  \Drupal::service('content_translation.manager')
    ->setEnabled('node', 'animal', 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[animal][enabled]' => 1,
    'node[animal][profiles]' => 'automatic',
    'node[animal][fields][title]' => 1,
    'node[animal][fields][body]' => 1,
    'node[animal][fields][field_image]' => 1,
    'node[animal][fields][field_image:properties][alt]' => 'alt',
  ];
  $this
    ->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-content-form');
}