function ImageStyleFlushTest::createSampleImage

Given an image style and a wrapper, generate an image.

1 call to ImageStyleFlushTest::createSampleImage()
ImageStyleFlushTest::testFlush in drupal/core/modules/image/lib/Drupal/image/Tests/ImageStyleFlushTest.php
General test to flush a style.

File

drupal/core/modules/image/lib/Drupal/image/Tests/ImageStyleFlushTest.php, line 26
Contains \Drupal\image\Tests\ImageStyleFlushTest.

Class

ImageStyleFlushTest
Tests flushing of image styles.

Namespace

Drupal\image\Tests

Code

function createSampleImage($style, $wrapper) {
  static $file;
  if (!isset($file)) {
    $files = $this
      ->drupalGetTestFiles('image');
    $file = reset($files);
  }

  // Make sure we have an image in our wrapper testing file directory.
  $source_uri = file_unmanaged_copy($file->uri, $wrapper . '://');

  // Build the derivative image.
  $derivative_uri = image_style_path($style
    ->id(), $source_uri);
  $derivative = image_style_create_derivative($style, $source_uri, $derivative_uri);
  return $derivative ? $derivative_uri : FALSE;
}