public function ImageOptimizePipelineTest::testNonExistentImagePipeline in Image Optimize (or ImageAPI Optimize) 8.3
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ImageOptimizePipelineTest.php \Drupal\Tests\imageapi_optimize\Kernel\ImageOptimizePipelineTest::testNonExistentImagePipeline()
- 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\KernelCode
public function testNonExistentImagePipeline() {
// Include special characters in the filename.
$image_uri = \Drupal::config('system.file')
->get('default_scheme') . '://Файл для тестирования ' . $this
->randomMachineName() . '.png';
$this
->assertFalse(is_file($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.');
}