You are here

public function TextimageApiTest::testFileExtensionCasing in Textimage 8.4

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

Test file extension casing.

File

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

Class

TextimageApiTest
Kernel tests for Textimage API.

Namespace

Drupal\Tests\textimage\Kernel

Code

public function testFileExtensionCasing() {

  // Ensure upper-casing in target image file extension is not a reason for
  // exceptions, and upper-cased extensions are lowered.
  // Get 'image-test.png' and rename to 'image-test.PNG'.
  $files = $this
    ->getTestFiles('image');
  $file = File::create((array) array_shift($files));
  $file
    ->save();
  file_move($file, 'image-test.PNG');
  $textimage = $this->textimageFactory
    ->get();
  $textimage
    ->setStyle(ImageStyle::load('textimage_test'))
    ->setSourceImageFile($file)
    ->setTargetExtension('PNG')
    ->process([
    'bingox',
  ])
    ->buildImage();
  $image = \Drupal::service('image.factory')
    ->get($textimage
    ->getUri());
  $this
    ->assertSame('image/png', $image
    ->getMimeType());
  $this
    ->assertSame('png', pathinfo($textimage
    ->getUri(), PATHINFO_EXTENSION));
}