You are here

public function ImageOptimizePipelineTest::testNonExistentImagePipeline in Image Optimize (or ImageAPI Optimize) 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/ImageOptimizePipelineTest.php \Drupal\Tests\imageapi_optimize\Kernel\ImageOptimizePipelineTest::testNonExistentImagePipeline()
  2. 4.x tests/src/Kernel/ImageOptimizePipelineTest.php \Drupal\Tests\imageapi_optimize\Kernel\ImageOptimizePipelineTest::testNonExistentImagePipeline()

Test the pipeline does not fail badly when image does not exist.

File

tests/src/Kernel/ImageOptimizePipelineTest.php, line 200

Class

ImageOptimizePipelineTest
Tests Image Optimize pipelines.

Namespace

Drupal\Tests\imageapi_optimize\Kernel

Code

public function testNonExistentImagePipeline() {

  // Include special characters in the filename.
  $image_uri = file_default_scheme() . '://Файл для тестирования ' . $this
    ->randomMachineName() . '.png';
  $this
    ->assertFileNotExists($image_uri, t('The test file does not exist on the disk.'));

  // Setup our pipeline.
  $pipeline = ImageAPIOptimizePipeline::create([
    'name' => 'test',
  ]);
  $pipeline
    ->addProcessor([
    'id' => 'imageapi_optimize_module_test_appendcharacters',
  ]);

  // Apply the pipeline.
  $result = $pipeline
    ->applyToImage($image_uri);

  // Check that the file was correctly 'optimized' to a black 1x1 PNG.
  $this
    ->assertFalse($result, 'Image pipeline failed to apply gracefully.');
}