WatermarkUpdateTest.php in Image Effects 8
File
src/Tests/Update/WatermarkUpdateTest.php
View source
<?php
namespace Drupal\image_effects\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
class WatermarkUpdateTest extends UpdatePathTestBase {
protected static $modules = [
'image_effects',
];
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../tests/fixtures/update/d_820_ie_810a2.php.gz',
__DIR__ . '/../../../tests/fixtures/update/test_watermark.php',
];
}
public function testWatermarkUpdate() {
$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']);
$this
->runUpdates();
$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));
}
}