public function ImageOptimizePipelineTest::testCompoundImagePipeline 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::testCompoundImagePipeline()
- 4.x tests/src/Kernel/ImageOptimizePipelineTest.php \Drupal\Tests\imageapi_optimize\Kernel\ImageOptimizePipelineTest::testCompoundImagePipeline()
Test procesors are cumulative.
File
- tests/
src/ Kernel/ ImageOptimizePipelineTest.php, line 110
Class
- ImageOptimizePipelineTest
- Tests Image Optimize pipelines.
Namespace
Drupal\Tests\imageapi_optimize\KernelCode
public function testCompoundImagePipeline() {
// Valid pink 1x1 PNG file.
$original_image_data = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==');
// Include special characters in the filename.
$image_uri = $this
->createUri('Файл для тестирования ' . $this
->randomMachineName() . '.png', $original_image_data);
// Check that our file has got to the filesystem correctly.
$this
->assertStringEqualsFile($image_uri, $original_image_data, 'Image data written to file successfully.');
// Setup our pipeline.
$pipeline = ImageAPIOptimizePipeline::create([
'name' => 'test',
]);
$pipeline
->addProcessor([
'id' => 'imageapi_optimize_module_test_appendcharacters',
]);
$pipeline
->addProcessor([
'id' => 'imageapi_optimize_module_test_appendcharacters',
]);
// Apply the pipeline.
$pipeline
->applyToImage($image_uri);
// Check that the file was correctly 'optimized': adding 20 '1' characters.
$this
->assertFileEqualsString($original_image_data . str_repeat('1', 20), $image_uri);
}