function CKEditorIntegrationTest::setUp

Same name in this branch
  1. 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\media_library\FunctionalJavascript\CKEditorIntegrationTest::setUp()
  2. 8.9.x core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest::setUp()
Same name in other branches
  1. 9 core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php, line 85

Class

CKEditorIntegrationTest
@coversDefaultClass \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia @group media

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

protected function setUp() {
    parent::setUp();
    FilterFormat::create([
        'format' => 'test_format',
        'name' => 'Test format',
        'filters' => [
            'filter_align' => [
                'status' => TRUE,
            ],
            'filter_caption' => [
                'status' => TRUE,
            ],
            'media_embed' => [
                'status' => TRUE,
            ],
        ],
    ])->save();
    Editor::create([
        'editor' => 'ckeditor',
        'format' => 'test_format',
        'settings' => [
            'toolbar' => [
                'rows' => [
                    [
                        [
                            'name' => 'All the things',
                            'items' => [
                                'Source',
                                'Bold',
                                'Italic',
                                'DrupalLink',
                                'DrupalUnlink',
                                'DrupalImage',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ])->save();
    // Note that media_install() grants 'view media' to all users by default.
    $this->adminUser = $this->drupalCreateUser([
        'use text format test_format',
        'bypass node access',
    ]);
    // Create a sample media entity to be embedded.
    $this->createMediaType('image', [
        'id' => 'image',
    ]);
    File::create([
        'uri' => $this->getTestFiles('image')[0]->uri,
    ])
        ->save();
    $this->media = Media::create([
        'bundle' => 'image',
        'name' => 'Screaming hairy armadillo',
        'field_media_image' => [
            [
                'target_id' => 1,
                'alt' => 'default alt',
                'title' => 'default title',
            ],
        ],
    ]);
    $this->media
        ->save();
    // Create a sample host entity to embed media in.
    $this->drupalCreateContentType([
        'type' => 'blog',
    ]);
    $this->host = $this->createNode([
        'type' => 'blog',
        'title' => 'Animals with strange names',
        'body' => [
            'value' => '<drupal-media data-caption="baz" data-entity-type="media" data-entity-uuid="' . $this->media
                ->uuid() . '"></drupal-media>',
            'format' => 'test_format',
        ],
    ]);
    $this->host
        ->save();
    $this->drupalLogin($this->adminUser);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.