You are here

protected function EditorFileUsageTest::setUp in Zircon Profile 8

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

Performs setup tasks before each individual test method is run.

Overrides EntityUnitTestBase::setUp

File

core/modules/editor/src/Tests/EditorFileUsageTest.php, line 28
Contains \Drupal\editor\Tests\EditorFileUsageTest.

Class

EditorFileUsageTest
Tests tracking of file usage by the Text Editor module.

Namespace

Drupal\editor\Tests

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('file');
  $this
    ->installSchema('node', array(
    'node_access',
  ));
  $this
    ->installSchema('file', array(
    'file_usage',
  ));
  $this
    ->installConfig([
    'node',
  ]);

  // Add text formats.
  $filtered_html_format = entity_create('filter_format', array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
    'filters' => array(),
  ));
  $filtered_html_format
    ->save();

  // Set cardinality for body field.
  FieldStorageConfig::loadByName('node', 'body')
    ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
    ->save();

  // Set up text editor.
  $editor = entity_create('editor', array(
    'format' => 'filtered_html',
    'editor' => 'unicorn',
  ));
  $editor
    ->save();

  // Create a node type for testing.
  $type = entity_create('node_type', array(
    'type' => 'page',
    'name' => 'page',
  ));
  $type
    ->save();
  node_add_body_field($type);
}