You are here

protected function CKEditorIntegrationTest::setUp in Entity Embed 8

Overrides BrowserTestBase::setUp

File

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

Class

CKEditorIntegrationTest
Tests ckeditor integration.

Namespace

Drupal\Tests\entity_embed\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->button = $this->container
    ->get('entity_type.manager')
    ->getStorage('embed_button')
    ->load('node');
  $settings = $this->button
    ->getTypeSettings();
  $settings['display_plugins'] = [
    'entity_reference:entity_reference_label',
  ];
  $this->button
    ->set('type_settings', $settings);
  $this->button
    ->save();
  $format = FilterFormat::create([
    'format' => 'embed_test',
    'name' => 'Embed format',
    'filters' => [],
  ]);
  $format
    ->save();
  Editor::create([
    'format' => 'embed_test',
    'editor' => 'ckeditor',
    'settings' => [
      'toolbar' => [
        'rows' => [
          [
            [
              'name' => 'Tools',
              'items' => [
                'Source',
                'Undo',
                'Redo',
              ],
            ],
          ],
        ],
      ],
    ],
  ])
    ->save();

  // Create a page content type.
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Basic page',
  ]);
  $this->adminUser = $this
    ->drupalCreateUser([
    'access administration pages',
    'administer filters',
    'administer display modes',
    'administer embed buttons',
    'administer site configuration',
    'administer display modes',
    'administer content types',
    'administer node display',
    'access content',
    'create page content',
    'edit own page content',
    $format
      ->getPermissionName(),
  ]);
  $this
    ->drupalLogin($this->adminUser);

  // Create a sample node.
  $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => 'Billy Bones',
    'body' => [
      'value' => 'He lacks two fingers.',
    ],
  ]);
  $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => 'Long John Silver',
    'body' => [
      'value' => 'A one-legged seafaring man.',
    ],
  ]);
}