You are here

protected function EditorUploadImageScaleTest::uploadImage in Drupal 8

Same name and namespace in other branches
  1. 9 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 201

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
    ->drupalPostForm('editor/dialog/image/basic_html', $edit, t('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(),
  ];
}