function ImageTest::testCanUploadSvg

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::testCanUploadSvg()

Tests that it's possible to upload SVG image, with the test module enabled.

File

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

Class

ImageTest
@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Image @group ckeditor5 @group #slow @internal

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testCanUploadSvg() : void {
    $this->container
        ->get('module_installer')
        ->install([
        'ckeditor5_test_module_allowed_image',
    ]);
    $page = $this->getSession()
        ->getPage();
    $src = 'core/modules/ckeditor5/tests/fixtures/test-svg-upload.svg';
    $this->drupalGet($this->host
        ->toUrl('edit-form'));
    $this->waitForEditor();
    $this->assertNotEmpty($image_upload_field = $page->find('css', '.ck-file-dialog-button input[type="file"]'));
    $image_upload_field->attachFile($this->container
        ->get('file_system')
        ->realpath($src));
    // Wait for the image to be uploaded and rendered by CKEditor 5.
    $this->assertNotEmpty($this->assertSession()
        ->waitForElementVisible('css', '.ck-widget.image-inline > img[src$="test-svg-upload.svg"]'));
}

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