function ImageStyleTest::testGetDerivativeExtension

Same name and namespace in other branches
  1. 9 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. 11.x 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 99

Class

ImageStyleTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21image%21src%21Entity%21ImageStyle.php/class/ImageStyle/8.9.x" title="Defines an image style configuration entity." class="local">\Drupal\image\Entity\ImageStyle</a>

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([
        [],
        $image_effect_id,
        [],
        $logger,
    ])
        ->getMock();
    $image_effect->expects($this->any())
        ->method('getDerivativeExtension')
        ->will($this->returnValue('png'));
    $image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
    $extensions = [
        'jpeg',
        'gif',
        'png',
    ];
    foreach ($extensions as $extension) {
        $extensionReturned = $image_style->getDerivativeExtension($extension);
        $this->assertEquals($extensionReturned, 'png');
    }
}

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