public function TextimageApiTest::testFileExtensionChange in Textimage 8.4
Same name and namespace in other branches
- 8.3 tests/src/Kernel/TextimageApiTest.php \Drupal\Tests\textimage\Kernel\TextimageApiTest::testFileExtensionChange()
Test changing image file extension via image effect.
File
- tests/
src/ Kernel/ TextimageApiTest.php, line 326
Class
- TextimageApiTest
- Kernel tests for Textimage API.
Namespace
Drupal\Tests\textimage\KernelCode
public function testFileExtensionChange() {
// Process, should generate a PNG image file.
$textimage = $this->textimageFactory
->get();
$textimage
->setStyle(ImageStyle::load('textimage_test'))
->process('bingo')
->buildImage();
$image = \Drupal::service('image.factory')
->get($textimage
->getUri());
$this
->assertSame('image/png', $image
->getMimeType());
// Add an extension change effect to the style.
$style = ImageStyle::load('textimage_test');
$style
->addImageEffect([
'id' => 'image_convert',
'data' => [
'extension' => 'jpeg',
],
]);
$style
->save();
// Process, should generate a JPEG image file.
$textimage = $this->textimageFactory
->get();
$textimage
->setStyle(ImageStyle::load('textimage_test'))
->process('bingo')
->buildImage();
$image = \Drupal::service('image.factory')
->get($textimage
->getUri());
$this
->assertSame('image/jpeg', $image
->getMimeType());
}