public function ImageAdminStylesTest::createSampleImage in Drupal 10
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::createSampleImage()
- 9 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::createSampleImage()
Given an image style, generate an image.
File
- core/
modules/ image/ tests/ src/ Functional/ ImageAdminStylesTest.php, line 34
Class
- ImageAdminStylesTest
- Tests creation, deletion, and editing of image styles and effects.
Namespace
Drupal\Tests\image\FunctionalCode
public function createSampleImage(ImageStyleInterface $style) {
static $file_path;
// First, we need to make sure we have an image in our testing
// file directory. Copy over an image on the first run.
if (!isset($file_path)) {
$files = $this
->drupalGetTestFiles('image');
$file = reset($files);
$file_path = \Drupal::service('file_system')
->copy($file->uri, 'public://');
}
return $style
->buildUrl($file_path) ? $file_path : FALSE;
}