You are here

protected function UrlEmbedTestBase::setUp in URL Embed 8

A set up for all tests.

Overrides BrowserTestBase::setUp

File

tests/src/Functional/UrlEmbedTestBase.php, line 61
Contains \Drupal\url_embed\Tests\UrlEmbedTestBase.

Class

UrlEmbedTestBase
Base class for all url_embed tests.

Namespace

Drupal\Tests\url_embed\Functional

Code

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

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

  // Create a text format and enable the url_embed filter.
  $format = FilterFormat::create([
    'format' => 'custom_format',
    'name' => 'Custom format',
    'filters' => [
      'url_embed' => [
        'status' => 1,
      ],
    ],
  ]);
  $format
    ->save();
  $editor_group = [
    'name' => 'URL Embed',
    'items' => [
      'url',
    ],
  ];
  $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(array(
    'access content',
    'create page content',
    'use text format custom_format',
  ));
  $this
    ->drupalLogin($this->webUser);
}