function ImageTest::setUp

Same name in this branch
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  2. 9 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
  3. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::setUp()
  4. 10 core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  5. 10 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()
  6. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::setUp()
  7. 11.x core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php \Drupal\KernelTests\Core\Theme\ImageTest::setUp()
  8. 11.x core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::setUp()

Overrides CKEditor5TestBase::setUp

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php, line 30

Class

ImageTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21ckeditor5%21src%21Plugin%21CKEditor5Plugin%21Image.php/class/Image/9" title="CKEditor 5 Image plugin." class="local">\Drupal\ckeditor5\Plugin\CKEditor5Plugin\Image</a> @group ckeditor5 @internal

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    FilterFormat::create([
        'format' => 'test_format',
        'name' => 'Test format',
        'filters' => [
            'filter_html' => [
                'status' => TRUE,
                'settings' => [
                    'allowed_html' => '<p> <br> <em> <a href> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>',
                ],
            ],
            'filter_align' => [
                'status' => TRUE,
            ],
            'filter_caption' => [
                'status' => TRUE,
            ],
        ],
    ])->save();
    Editor::create([
        'editor' => 'ckeditor5',
        'format' => 'test_format',
        'settings' => [
            'toolbar' => [
                'items' => [
                    'drupalInsertImage',
                    'sourceEditing',
                    'link',
                    'italic',
                ],
            ],
            'plugins' => [
                'ckeditor5_sourceEditing' => [
                    'allowed_tags' => [],
                ],
                'ckeditor5_imageResize' => [
                    'allow_resize' => TRUE,
                ],
            ],
        ],
        'image_upload' => [
            'status' => TRUE,
            'scheme' => 'public',
            'directory' => 'inline-images',
            'max_size' => '1M',
            'max_dimensions' => [
                'width' => 100,
                'height' => 100,
            ],
        ],
    ])->save();
    $this->assertSame([], array_map(function (ConstraintViolation $v) {
        return (string) $v->getMessage();
    }, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
    $this->adminUser = $this->drupalCreateUser([
        'use text format test_format',
        'bypass node access',
        'administer filters',
    ]);
    // Create a sample host entity to embed images in.
    $this->file = File::create([
        'uri' => $this->getTestFiles('image')[0]->uri,
    ]);
    $this->file
        ->save();
    $this->host = $this->createNode([
        'type' => 'page',
        'title' => 'Animals with strange names',
        'body' => [
            'value' => '<p>The pirate is irate.</p>',
            '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.