function ImageStyleTest::testGetDerivativeExtension

Same name and namespace in other branches
  1. 11.x core/modules/image/tests/src/Unit/ImageStyleTest.php \Drupal\Tests\image\Unit\ImageStyleTest::testGetDerivativeExtension()
  2. 10 core/modules/image/tests/src/Unit/ImageStyleTest.php \Drupal\Tests\image\Unit\ImageStyleTest::testGetDerivativeExtension()
  3. 9 core/modules/image/tests/src/Unit/ImageStyleTest.php \Drupal\Tests\image\Unit\ImageStyleTest::testGetDerivativeExtension()
  4. 8.9.x core/modules/image/tests/src/Unit/ImageStyleTest.php \Drupal\Tests\image\Unit\ImageStyleTest::testGetDerivativeExtension()

Tests get derivative extension.

File

core/modules/image/tests/src/Unit/ImageStyleTest.php, line 106

Class

ImageStyleTest
Tests Drupal\image\Entity\ImageStyle.

Namespace

Drupal\Tests\image\Unit

Code

public function testGetDerivativeExtension() : void {
  $image_effect_id = $this->randomMachineName();
  $image_effect = $this->createStub(ImageEffectBase::class);
  $image_effect->method('getDerivativeExtension')
    ->willReturn('png');
  $image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
  $image_style->expects($this->once())
    ->method('getImageEffectPluginManager');
  $extensions = [
    'jpeg',
    'gif',
    'png',
  ];
  foreach ($extensions as $extension) {
    $extensionReturned = $image_style->getDerivativeExtension($extension);
    $this->assertEquals('png', $extensionReturned);
  }
}

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