You are here

public function ImageStyleWarmerDrushTest::prepareImageStyleWarmerTests in Image Style Warmer 8

Prepare Image Style Warmer settings and file for tests.

Parameters

bool $permanent: Create permanent file for tests. (default: FALSE)

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to ImageStyleWarmerDrushTest::prepareImageStyleWarmerTests()
ImageStyleWarmerDrushTest::testDrushWarmUp in tests/src/Functional/ImageStyleWarmerDrushTest.php
Tests Image Style Warmer warm-up via Drush command.

File

tests/src/Functional/ImageStyleWarmerDrushTest.php, line 50

Class

ImageStyleWarmerDrushTest
Tests the Drush commands provided by Image Style Warmer.

Namespace

Drupal\Tests\image_style_warmer\Functional

Code

public function prepareImageStyleWarmerTests($permanent = FALSE) {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/config/development/performance/image-style-warmer');
  $settings = [
    'initial_image_styles[test_initial]' => 'test_initial',
    'queue_image_styles[test_queue]' => 'test_queue',
  ];
  $this
    ->drupalPostForm('admin/config/development/performance/image-style-warmer', $settings, t('Save configuration'));

  // Create an image file without usages.
  $this->testFile = $this
    ->getTestFile('image');
  $this->testFile
    ->setTemporary();
  if ($permanent) {
    $this->testFile
      ->setPermanent();
  }
  $this->testFile
    ->save();
}