You are here

protected function BlazyCreationTestTrait::setUpRealImage in Blazy 8.2

Same name and namespace in other branches
  1. 8 tests/src/Traits/BlazyCreationTestTrait.php \Drupal\Tests\blazy\Traits\BlazyCreationTestTrait::setUpRealImage()

Set up dummy image.

6 calls to BlazyCreationTestTrait::setUpRealImage()
BlazyEntityTest::setUp in tests/src/Kernel/BlazyEntityTest.php
Set the default field storage backend for fields created during tests.
BlazyFilterJavaScriptTest::setUp in tests/src/FunctionalJavascript/BlazyFilterJavaScriptTest.php
BlazyFormatterTest::setUp in tests/src/Kernel/BlazyFormatterTest.php
Set the default field storage backend for fields created during tests.
BlazyManagerTest::setUp in tests/src/Kernel/BlazyManagerTest.php
Set the default field storage backend for fields created during tests.
BlazyViewsFileTest::buildContents in tests/src/Kernel/Views/BlazyViewsFileTest.php
Build contents.

... See full list

File

tests/src/Traits/BlazyCreationTestTrait.php, line 475

Class

BlazyCreationTestTrait
A Trait common for Blazy tests.

Namespace

Drupal\Tests\blazy\Traits

Code

protected function setUpRealImage() {
  $this->uri = $this
    ->getImagePath();
  $item = $this->dummyItem;
  if (isset($this->testItems[0])) {
    $item = $this->testItems[0];
    if ($item instanceof ImageItem) {
      $this->uri = ($entity = $item->entity) && empty($item->uri) ? $entity
        ->getFileUri() : $item->uri;
      $this->url = file_url_transform_relative(file_create_url($this->uri));
    }
  }
  if (empty($this->url)) {
    $source = $this->root . '/core/misc/druplicon.png';
    $uri = 'public://test.png';
    $this->fileSystem
      ->copy($source, $uri, FileSystemInterface::EXISTS_REPLACE);
    $this->url = file_create_url($uri);
  }
  $this->testItem = $this->image = $item;
  $this->data = [
    'settings' => $this
      ->getFormatterSettings(),
    'item' => $item,
  ];
  $this->imageFactory = $this->container
    ->get('image.factory');
}