You are here

public function ImageStyleTest::testGetDerivativeExtension in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/image/tests/src/Unit/ImageStyleTest.php \Drupal\Tests\image\Unit\ImageStyleTest::testGetDerivativeExtension()

@covers ::getDerivativeExtension

File

core/modules/image/tests/src/Unit/ImageStyleTest.php, line 110
Contains \Drupal\Tests\image\Unit\ImageStyleTest.

Class

ImageStyleTest
@coversDefaultClass \Drupal\image\Entity\ImageStyle

Namespace

Drupal\Tests\image\Unit

Code

public function testGetDerivativeExtension() {
  $image_effect_id = $this
    ->randomMachineName();
  $logger = $this
    ->getMockBuilder('\\Psr\\Log\\LoggerInterface')
    ->getMock();
  $image_effect = $this
    ->getMockBuilder('\\Drupal\\image\\ImageEffectBase')
    ->setConstructorArgs(array(
    array(),
    $image_effect_id,
    array(),
    $logger,
  ))
    ->getMock();
  $image_effect
    ->expects($this
    ->any())
    ->method('getDerivativeExtension')
    ->will($this
    ->returnValue('png'));
  $image_style = $this
    ->getImageStyleMock($image_effect_id, $image_effect);
  $extensions = array(
    'jpeg',
    'gif',
    'png',
  );
  foreach ($extensions as $extension) {
    $extensionReturned = $image_style
      ->getDerivativeExtension($extension);
    $this
      ->assertEquals($extensionReturned, 'png');
  }
}