function EditorUploadImageScaleTest::uploadImage

Same name and namespace in other branches
  1. 9 core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php \Drupal\Tests\editor\Functional\EditorUploadImageScaleTest::uploadImage()
  2. 8.9.x core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php \Drupal\Tests\editor\Functional\EditorUploadImageScaleTest::uploadImage()

Uploads an image via the editor dialog.

Parameters

string $uri: The URI of the image.

Return value

array An array containing the uploaded image's width and height.

1 call to EditorUploadImageScaleTest::uploadImage()
EditorUploadImageScaleTest::testEditorUploadImageScale in core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php
Tests scaling of inline images.

File

core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php, line 202

Class

EditorUploadImageScaleTest
Tests scaling of inline images.

Namespace

Drupal\Tests\editor\Functional

Code

protected function uploadImage($uri) {
  $edit = [
    'files[fid]' => \Drupal::service('file_system')->realpath($uri),
  ];
  $this->drupalGet('editor/dialog/image/basic_html');
  $this->drupalGet('editor/dialog/image/basic_html');
  $this->submitForm($edit, 'Upload');
  $uploaded_image_file = $this->container
    ->get('image.factory')
    ->get('public://inline-images/' . basename($uri));
  return [
    (int) $uploaded_image_file->getWidth(),
    (int) $uploaded_image_file->getHeight(),
  ];
}

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