function TextPlainUnitTest::setUp

Sets up Drupal unit test environment.

Overrides DrupalUnitTestBase::setUp

See also

DrupalUnitTestBase::$modules

DrupalUnitTestBase

File

drupal/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php, line 46
Contains \Drupal\text\Tests\Formatter\TextPlainUnitTest.

Class

TextPlainUnitTest
Tests the text_plain field formatter.

Namespace

Drupal\text\Tests\Formatter

Code

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

  // Configure the theme system.
  $this
    ->installConfig(array(
    'system',
    'field',
  ));
  $this
    ->installSchema('entity_test', 'entity_test');

  // @todo Add helper methods for all of the following.
  $this->entity_type = 'entity_test';
  if (!isset($this->bundle)) {
    $this->bundle = $this->entity_type;
  }
  $this->field_name = drupal_strtolower($this
    ->randomName());
  $this->field_type = 'text_long';
  $this->field_settings = array();
  $this->instance_settings = array(
    'text_processing' => FALSE,
  );
  $this->formatter_type = 'text_plain';
  $this->formatter_settings = array();
  $this->field = array(
    'field_name' => $this->field_name,
    'type' => $this->field_type,
    'settings' => $this->field_settings,
  );
  $this->field = field_create_field($this->field);
  $this->instance = array(
    'entity_type' => $this->entity_type,
    'bundle' => $this->bundle,
    'field_name' => $this->field_name,
    'label' => $this
      ->randomName(),
    'settings' => $this->instance_settings,
  );
  $this->instance = field_create_instance($this->instance);
  $this->view_mode = 'default';
  $this->display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode)
    ->setComponent($this->field_name, array(
    'type' => $this->formatter_type,
    'settings' => $this->formatter_settings,
  ));
  $this->display
    ->save();
  $this->langcode = Language::LANGCODE_NOT_SPECIFIED;
}