You are here

public function ImageStyleWarmerCustomModuleTest::testImageStyleWarmerQueueCustomModule in Image Style Warmer 8

Test Image Style Warmer queue warming like a custom module.

File

tests/src/Functional/ImageStyleWarmerCustomModuleTest.php, line 64

Class

ImageStyleWarmerCustomModuleTest
Functional tests to check Image Style Warmer usage like a custom module.

Namespace

Drupal\Tests\image_style_warmer\Functional

Code

public function testImageStyleWarmerQueueCustomModule() {
  $this
    ->prepareImageStyleWarmerCustomModuleTests();

  // Add image file to Image Style Warmer queue like a custom module.
  $this->testService
    ->addQueue($this->testFile, [
    $this->testQueueStyle
      ->id(),
  ]);
  $this
    ->assertSame(1, $this->testQueue
    ->numberOfItems(), 'Image Style Warmer Pregenerator queue should not be empty.');
  $this
    ->assertFalse(file_exists($this->testQueueStyle
    ->buildUri($this->testFile
    ->getFileUri())), 'Generated file does not exist.');
  $this
    ->cronRun();
  $this
    ->assertSame(0, $this->testQueue
    ->numberOfItems(), 'Image Style Warmer Pregenerator queue should be empty.');
  $this
    ->assertTrue(file_exists($this->testQueueStyle
    ->buildUri($this->testFile
    ->getFileUri())), 'Generated file does exist.');
}