function ToolkitGdTest::testSupportedExtensions

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::testSupportedExtensions()
  2. 11.x core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::testSupportedExtensions()

@covers ::getSupportedExtensions @covers ::extensionToImageType

File

core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php, line 359

Class

ToolkitGdTest
Tests for the GD image toolkit.

Namespace

Drupal\KernelTests\Core\Image

Code

public function testSupportedExtensions() : void {
    // Test the list of supported extensions.
    $expected_extensions = [
        'png',
        'gif',
        'jpeg',
        'jpg',
        'jpe',
        'webp',
    ];
    $this->assertEqualsCanonicalizing($expected_extensions, $this->imageFactory
        ->getSupportedExtensions());
    // Test that the supported extensions map to correct internal GD image
    // types.
    $expected_image_types = [
        'png' => IMAGETYPE_PNG,
        'gif' => IMAGETYPE_GIF,
        'jpeg' => IMAGETYPE_JPEG,
        'jpg' => IMAGETYPE_JPEG,
        'jpe' => IMAGETYPE_JPEG,
        'webp' => IMAGETYPE_WEBP,
    ];
    $image = $this->imageFactory
        ->get();
    foreach ($expected_image_types as $extension => $expected_image_type) {
        $this->assertSame($expected_image_type, $image->getToolkit()
            ->extensionToImageType($extension));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.