You are here

protected function FootnotesCkeditorPluginTest::setUp in Footnotes 8.2

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/FootnotesCkeditorPluginTest.php, line 53

Class

FootnotesCkeditorPluginTest
Contains Footnotes CKEditor plugin functionality tests.

Namespace

Drupal\Tests\footnotes\FunctionalJavascript

Code

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

  // Create a text format and associate CKEditor.
  $this->filterFormat = FilterFormat::create([
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'filters' => [
      'filter_footnotes' => [
        'status' => TRUE,
        'settings' => [
          'footnotes_collapse' => 0,
          'footnotes_html' => 0,
        ],
      ],
    ],
  ]);
  $this->filterFormat
    ->save();
  Editor::create([
    'format' => 'filtered_html',
    'editor' => 'ckeditor',
    'settings' => [
      'toolbar' => [
        'rows' => [
          [
            [
              'name' => 'All the things',
              'items' => [
                'Source',
                'Bold',
                'Italic',
                'footnotes',
              ],
            ],
          ],
        ],
      ],
    ],
  ])
    ->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);
}