You are here

protected function EntityEmbedDialogTest::setUp in Entity Embed 8

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/EntityEmbedDialogTest.php, line 40

Class

EntityEmbedDialogTest
Tests the entity_embed dialog controller and route.

Namespace

Drupal\Tests\entity_embed\FunctionalJavascript

Code

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

  // Create a page content type.
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Basic page',
  ]);

  // Create a text format and enable the entity_embed filter.
  $format = FilterFormat::create([
    'format' => 'custom_format',
    'name' => 'Custom format',
    'filters' => [
      'entity_embed' => [
        'status' => 1,
      ],
    ],
  ]);
  $format
    ->save();
  $editor_group = [
    'name' => 'Entity Embed',
    'items' => [
      'node',
    ],
  ];
  $editor = Editor::create([
    'format' => 'custom_format',
    'editor' => 'ckeditor',
    'settings' => [
      'toolbar' => [
        'rows' => [
          [
            $editor_group,
          ],
        ],
      ],
    ],
  ]);
  $editor
    ->save();

  // Create a user with required permissions.
  $this->webUser = $this
    ->drupalCreateUser([
    'access content',
    'create page content',
    'use text format custom_format',
  ]);
  $this
    ->drupalLogin($this->webUser);

  // Create a sample node to be embedded.
  $settings = [];
  $settings['type'] = 'page';
  $settings['title'] = 'Embed Test Node';
  $settings['body'] = [
    'value' => 'This node is to be used for embedding in other nodes.',
    'format' => 'custom_format',
  ];
  $this->node = $this
    ->drupalCreateNode($settings);
}