You are here

protected function CKEditorIntegrationTest::setUp in Drupal 8

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

Overrides BrowserTestBase::setUp

File

core/modules/media_library/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php, line 59

Class

CKEditorIntegrationTest
@coversDefaultClass \Drupal\media_library\Plugin\CKEditorPlugin\DrupalMediaLibrary @group media_library

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  FilterFormat::create([
    'format' => 'test_format',
    'name' => 'Test format',
    'filters' => [
      'media_embed' => [
        'status' => TRUE,
      ],
    ],
  ])
    ->save();
  Editor::create([
    'editor' => 'ckeditor',
    'format' => 'test_format',
    'settings' => [
      'toolbar' => [
        'rows' => [
          [
            [
              'name' => 'Main',
              'items' => [
                'Source',
                'Undo',
                'Redo',
              ],
            ],
          ],
          [
            [
              'name' => 'Embeds',
              'items' => [
                'DrupalMediaLibrary',
              ],
            ],
          ],
        ],
      ],
    ],
  ])
    ->save();
  $this
    ->drupalCreateContentType([
    'type' => 'blog',
  ]);

  // Note that media_install() grants 'view media' to all users by default.
  $this->user = $this
    ->drupalCreateUser([
    'use text format test_format',
    'access media overview',
    'create blog content',
  ]);

  // Create a media type that starts with the letter a, to test tab order.
  $this
    ->createMediaType('image', [
    'id' => 'arrakis',
    'label' => 'Arrakis',
  ]);

  // Create a sample media entity to be embedded.
  $this
    ->createMediaType('image', [
    'id' => 'image',
    'label' => 'Image',
  ]);
  File::create([
    'uri' => $this
      ->getTestFiles('image')[0]->uri,
  ])
    ->save();
  $this->media = Media::create([
    'bundle' => 'image',
    'name' => 'Fear is the mind-killer',
    'field_media_image' => [
      [
        'target_id' => 1,
        'alt' => 'default alt',
        'title' => 'default title',
      ],
    ],
  ]);
  $this->media
    ->save();
  $arrakis_media = Media::create([
    'bundle' => 'arrakis',
    'name' => 'Le baron Vladimir Harkonnen',
    'field_media_image' => [
      [
        'target_id' => 1,
        'alt' => 'Il complote pour détruire le duc Leto',
        'title' => 'Il complote pour détruire le duc Leto',
      ],
    ],
  ]);
  $arrakis_media
    ->save();
  $this
    ->drupalLogin($this->user);
}