function ImageTestBase::testResize

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

Tests the image resize plugin.

Confirms that enabling the resize plugin introduces the resize class to images within CKEditor 5.

@dataProvider providerResize

Parameters

bool $is_resize_enabled: Boolean flag to test enabled or disabled.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTestBase.php, line 622

Class

ImageTestBase
@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Image @group ckeditor5 @internal

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testResize(bool $is_resize_enabled) : void {
    // Disable resize plugin because it is enabled by default.
    if (!$is_resize_enabled) {
        Editor::load('test_format')->setSettings([
            'toolbar' => [
                'items' => [
                    'drupalInsertImage',
                ],
            ],
            'plugins' => [
                'ckeditor5_imageResize' => [
                    'allow_resize' => FALSE,
                ],
            ],
        ])
            ->save();
    }
    $page = $this->getSession()
        ->getPage();
    $assert_session = $this->assertSession();
    $this->drupalGet('node/add');
    $page->fillField('title[0][value]', 'My test content');
    $this->addImage();
    $image_figure = $assert_session->waitForElementVisible('css', 'figure');
    $this->assertSame($is_resize_enabled, $image_figure->hasClass('ck-widget_with-resizer'));
}

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