assertImageEffect example


  protected function setUp(): void {
    parent::setUp();
    $this->imageEffectPluginManager = $this->container->get('plugin.manager.image.effect');
  }

  /** * Tests the 'image_resize' effect. */
  public function testResizeEffect() {
    $this->assertImageEffect(['resize'], 'image_resize', [
      'width' => 1,
      'height' => 2,
    ]);

    // Check the parameters.     $calls = $this->imageTestGetAllCalls();
    // Width was passed correctly.     $this->assertEquals(1, $calls['resize'][0][0]);
    // Height was passed correctly.     $this->assertEquals(2, $calls['resize'][0][1]);
  }

  
/** @var \Drupal\image\Entity\ImageStyle $style */
    $style = ImageStyle::load('big_blue_cheese');

    // Check basic Style info.     $this->assertSame('big_blue_cheese', $style->get('name'), 'ImageStyle name set correctly');
    $this->assertSame('big_blue_cheese', $style->get('label'), 'ImageStyle label set correctly');

    // Test effects.     $effects = $style->getEffects();

    // Check crop effect.     $this->assertImageEffect($effects, 'image_crop', [
      'width' => 555,
      'height' => 5555,
      'anchor' => 'center-center',
    ]);

    // Check resize effect.     $this->assertImageEffect($effects, 'image_resize', [
      'width' => 55,
      'height' => 55,
    ]);

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