You are here

public function ImageTest::testResize in Drupal 10

Same name in this branch
  1. 10 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::testResize()
  2. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/ImageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\ImageTest::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/ImageTest.php, line 671

Class

ImageTest
@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ImageUpload @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' => [
          'uploadImage',
        ],
      ],
      '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
    ->assertNotEmpty($image_upload_field = $page
    ->find('css', '.ck-file-dialog-button input[type="file"]'));
  $image = $this
    ->getTestFiles('image')[0];
  $image_upload_field
    ->attachFile($this->container
    ->get('file_system')
    ->realpath($image->uri));
  $image_figure = $assert_session
    ->waitForElementVisible('css', 'figure');
  $this
    ->assertSame($is_resize_enabled, $image_figure
    ->hasClass('ck-widget_with-resizer'));
}