You are here

public function TextimageApiTest::testForceTargetExtension in Textimage 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/TextimageApiTest.php \Drupal\Tests\textimage\Kernel\TextimageApiTest::testForceTargetExtension()

Test forcing an extension different from source image file.

File

tests/src/Kernel/TextimageApiTest.php, line 235

Class

TextimageApiTest
Kernel tests for Textimage API.

Namespace

Drupal\Tests\textimage\Kernel

Code

public function testForceTargetExtension() {
  $files = $this
    ->getTestFiles('image');

  // Get 'image-test.png'.
  $file = File::create((array) array_shift($files));
  $file
    ->save();

  // Force GIF.
  $textimage = $this->textimageFactory
    ->get();
  $textimage
    ->setStyle(ImageStyle::load('textimage_test'))
    ->setSourceImageFile($file)
    ->setTargetExtension('gif')
    ->process([
    'bingox',
  ])
    ->buildImage();
  $image = \Drupal::service('image.factory')
    ->get($textimage
    ->getUri());
  $this
    ->assertSame('image/gif', $image
    ->getMimeType());
}