You are here

protected function TinyMCEIntegrationTest::setUp in TinyMCE 1.x

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/TinyMCEIntegrationTest.php, line 47

Class

TinyMCEIntegrationTest
Tests the integration of TinyMCE.

Namespace

Drupal\Tests\tinymce\FunctionalJavascript

Code

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

  // Create a text format and associate TinyMCE.
  $this->filterFormat = FilterFormat::create([
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'weight' => 0,
  ]);
  $this->filterFormat
    ->save();
  Editor::create([
    'format' => 'filtered_html',
    'editor' => 'tinymce',
  ])
    ->save();

  // Create a node type for testing.
  NodeType::create([
    'type' => 'page',
    'name' => 'page',
  ])
    ->save();
  $field_storage = FieldStorageConfig::loadByName('node', 'body');

  // Create a body field instance for the 'page' node type.
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'page',
    'label' => 'Body',
    'settings' => [
      'display_summary' => TRUE,
    ],
    'required' => TRUE,
  ])
    ->save();

  // Assign widget settings for the 'default' form mode.
  EntityFormDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => 'page',
    'mode' => 'default',
    'status' => TRUE,
  ])
    ->setComponent('body', [
    'type' => 'text_textarea_with_summary',
  ])
    ->save();
  $this->account = $this
    ->drupalCreateUser([
    'administer nodes',
    'create page content',
    'use text format filtered_html',
  ]);
  $this
    ->drupalLogin($this->account);
}