You are here

function ImageStyleFlushTest::createSampleImage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/image/src/Tests/ImageStyleFlushTest.php \Drupal\image\Tests\ImageStyleFlushTest::createSampleImage()

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

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

File

core/modules/image/src/Tests/ImageStyleFlushTest.php, line 22
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 = $style
    ->buildUri($source_uri);
  $derivative = $style
    ->createDerivative($source_uri, $derivative_uri);
  return $derivative ? $derivative_uri : FALSE;
}