You are here

public function WatermarkUpdateTest::testWatermarkUpdate in Image Effects 8

Tests that 'Watermark' effects are updated properly.

File

src/Tests/Update/WatermarkUpdateTest.php, line 34

Class

WatermarkUpdateTest
Tests the upgrade path for 'watermark' effect.

Namespace

Drupal\image_effects\Tests\Update

Code

public function testWatermarkUpdate() {

  // Test that Watermark effect has parameters as valid before
  // 8.x-1.0-alpha6.
  $effect_data = $this
    ->config('image.style.test_watermark_scale')
    ->get('effects.3d493386-5251-4d45-b395-2e036f7203c0.data');
  $this
    ->assertFalse(array_key_exists('watermark_width', $effect_data));
  $this
    ->assertFalse(array_key_exists('watermark_height', $effect_data));
  $this
    ->assertIdentical(10, $effect_data['x_offset']);
  $this
    ->assertIdentical(10, $effect_data['y_offset']);
  $this
    ->assertIdentical(20, $effect_data['watermark_scale']);
  $effect_data = $this
    ->config('image.style.test_watermark_no_scale')
    ->get('effects.253dcaa0-27f0-49ef-9d5f-4bda9bf78ff7.data');
  $this
    ->assertFalse(array_key_exists('watermark_width', $effect_data));
  $this
    ->assertFalse(array_key_exists('watermark_height', $effect_data));
  $this
    ->assertIdentical(10, $effect_data['x_offset']);
  $this
    ->assertIdentical(10, $effect_data['y_offset']);
  $this
    ->assertNull($effect_data['watermark_scale']);

  // Run updates.
  $this
    ->runUpdates();

  // Test that Watermark effect has parameters as introduced in
  // 8.x-1.0-alpha6.
  $effect_data = $this
    ->config('image.style.test_watermark_scale')
    ->get('effects.3d493386-5251-4d45-b395-2e036f7203c0.data');
  $this
    ->assertTrue(array_key_exists('watermark_width', $effect_data));
  $this
    ->assertTrue(array_key_exists('watermark_height', $effect_data));
  $this
    ->assertIdentical('10', $effect_data['x_offset']);
  $this
    ->assertIdentical('10', $effect_data['y_offset']);
  $this
    ->assertIdentical('20%', $effect_data['watermark_width']);
  $this
    ->assertFalse(array_key_exists('watermark_scale', $effect_data));
  $effect_data = $this
    ->config('image.style.test_watermark_no_scale')
    ->get('effects.253dcaa0-27f0-49ef-9d5f-4bda9bf78ff7.data');
  $this
    ->assertTrue(array_key_exists('watermark_width', $effect_data));
  $this
    ->assertTrue(array_key_exists('watermark_height', $effect_data));
  $this
    ->assertIdentical('10', $effect_data['x_offset']);
  $this
    ->assertIdentical('10', $effect_data['y_offset']);
  $this
    ->assertNull($effect_data['watermark_width']);
  $this
    ->assertFalse(array_key_exists('watermark_scale', $effect_data));
}