You are here

protected function ContentTranslationContextualLinksTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php \Drupal\content_translation\Tests\ContentTranslationContextualLinksTest::setUp()

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 WebTestBase::setUp

File

core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php, line 64
Contains \Drupal\content_translation\Tests\ContentTranslationContextualLinksTest.

Class

ContentTranslationContextualLinksTest
Tests that contextual links are available for content translation.

Namespace

Drupal\content_translation\Tests

Code

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

  // Set up an additional language.
  $this->langcodes = array(
    \Drupal::languageManager()
      ->getDefaultLanguage()
      ->getId(),
    'es',
  );
  ConfigurableLanguage::createFromLangcode('es')
    ->save();

  // Create a content type.
  $this->bundle = $this
    ->randomMachineName();
  $this->contentType = $this
    ->drupalCreateContentType(array(
    'type' => $this->bundle,
  ));

  // Add a field to the content type. The field is not yet translatable.
  entity_create('field_storage_config', array(
    'field_name' => 'field_test_text',
    'entity_type' => 'node',
    'type' => 'text',
    'cardinality' => 1,
  ))
    ->save();
  entity_create('field_config', array(
    'entity_type' => 'node',
    'field_name' => 'field_test_text',
    'bundle' => $this->bundle,
    'label' => 'Test text-field',
  ))
    ->save();
  entity_get_form_display('node', $this->bundle, 'default')
    ->setComponent('field_test_text', array(
    'type' => 'text_textfield',
    'weight' => 0,
  ))
    ->save();

  // Create a translator user.
  $permissions = array(
    'access contextual links',
    'administer nodes',
    "edit any {$this->bundle} content",
    'translate any entity',
  );
  $this->translator = $this
    ->drupalCreateUser($permissions);
}