getDerivativeExtension example

$image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
      ->setConstructorArgs([[]$image_effect_id[]$logger])
      ->getMock();
    $image_effect->expects($this->any())
      ->method('getDerivativeExtension')
      ->willReturn('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('png', $extensionReturned);
    }
  }

  /** * @covers ::buildUri */
  public function testBuildUri() {
    // Image style that changes the extension.     $image_effect_id = $this->randomMachineName();
    $logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
    
public function transformDimensions(array &$dimensions$uri) {
    foreach ($this->getEffects() as $effect) {
      $effect->transformDimensions($dimensions$uri);
    }
  }

  /** * {@inheritdoc} */
  public function getDerivativeExtension($extension) {
    foreach ($this->getEffects() as $effect) {
      $extension = $effect->getDerivativeExtension($extension);
    }
    return $extension;
  }

  /** * {@inheritdoc} */
  public function getPathToken($uri) {
    // Return the first 8 characters.     return substr(Crypt::hmacBase64($this->id() . ':' . $this->addExtension($uri)$this->getPrivateKey() . $this->getHashSalt()), 0, 8);
  }

  
Home | Imprint | This part of the site doesn't use cookies.