function ImageAdminStylesTest::createSampleImage
Same name in other branches
- 9 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::createSampleImage()
- 8.9.x core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::createSampleImage()
- 10 core/modules/image/tests/src/Functional/ImageAdminStylesTest.php \Drupal\Tests\image\Functional\ImageAdminStylesTest::createSampleImage()
Given an image style, generate an image.
1 call to ImageAdminStylesTest::createSampleImage()
- ImageAdminStylesTest::testStyle in core/
modules/ image/ tests/ src/ Functional/ ImageAdminStylesTest.php - General test to add a style, add/remove/edit effects to it, then delete it.
File
-
core/
modules/ image/ tests/ src/ Functional/ ImageAdminStylesTest.php, line 35
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.