protected function BlazyCreationTestTrait::createDummyImage in Blazy 8.2
Same name and namespace in other branches
- 8 tests/src/Traits/BlazyCreationTestTrait.php \Drupal\Tests\blazy\Traits\BlazyCreationTestTrait::createDummyImage()
Returns the created image file.
1 call to BlazyCreationTestTrait::createDummyImage()
- BlazyCreationTestTrait::getImagePath in tests/
src/ Traits/ BlazyCreationTestTrait.php - Returns path to the stored image location.
File
- tests/
src/ Traits/ BlazyCreationTestTrait.php, line 524
Class
- BlazyCreationTestTrait
- A Trait common for Blazy tests.
Namespace
Drupal\Tests\blazy\TraitsCode
protected function createDummyImage($name = '', $source = '') {
$path = $this->root . '/sites/default/files/simpletest/' . $this->testPluginId;
$name = empty($name) ? $this->testPluginId . '.png' : $name;
$source = empty($source) ? $this->root . '/core/misc/druplicon.png' : $source;
$uri = $path . '/' . $name;
if (!is_file($uri)) {
$this
->prepareTestDirectory();
$this->fileSystem
->saveData($source, $uri, FileSystemInterface::EXISTS_REPLACE);
}
$uri = 'public://simpletest/' . $this->testPluginId . '/' . $name;
$this->dummyUri = $uri;
$item = File::create([
'uri' => $uri,
'uid' => 1,
'status' => FILE_STATUS_PERMANENT,
'filename' => $name,
]);
$item
->save();
return $item;
}