Skip to content
Snippets Groups Projects
Commit 7f4e7eb6 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2807893 by svendecabooter: Convert Image's Migrate source tests to new base class

parent a53da806
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\Tests\image\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the d6_imagecache_presets source plugin.
*
* @covers \Drupal\image\Plugin\migrate\source\d6\ImageCachePreset
*
* @group image
*/
class ImageCachePresetTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['image', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['imagecache_preset'] = [
[
'presetid' => '1',
'presetname' => 'slackjaw_boys',
],
];
$tests[0]['source_data']['imagecache_action'] = [
[
'actionid' => '3',
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_scale_and_crop',
'data' => 'a:2:{s:5:"width";s:4:"100%";s:6:"height";s:4:"100%";}',
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'presetid' => '1',
'presetname' => 'slackjaw_boys',
'actions' => [
[
'actionid' => '3',
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_scale_and_crop',
'data' => [
'width' => '100%',
'height' => '100%',
],
],
],
],
];
return $tests;
}
}
<?php
namespace Drupal\Tests\image\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the D7 ImageStyles source plugin.
*
* @covers \Drupal\image\Plugin\migrate\source\d7\ImageStyles
*
* @group image
*/
class ImageStylesTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['image', 'migrate_drupal'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['image_styles'] = [
[
'isid' => 1,
'name' => 'custom_image_style_1',
'label' => 'Custom image style 1',
],
];
$tests[0]['source_data']['image_effects'] = [
[
'ieid' => 1,
'isid' => 1,
'weight' => 1,
'name' => 'image_desaturate',
'data' => serialize(array()),
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'isid' => 1,
'name' => 'custom_image_style_1',
'label' => 'Custom image style 1',
'effects' => [
[
'ieid' => 1,
'isid' => 1,
'weight' => 1,
'name' => 'image_desaturate',
'data' => [],
],
],
],
];
return $tests;
}
}
<?php
namespace Drupal\Tests\image\Unit\Plugin\migrate\source\d6;
use Drupal\image\Plugin\migrate\source\d6\ImageCachePreset;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests the d6_imagecache_presets source plugin.
*
* @group image
*/
class ImageCachePresetTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = ImageCachePreset::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_imagecache_presets',
),
);
protected $expectedResults = array(
array(
'presetid' => '1',
'presetname' => 'slackjaw_boys',
'actions' => array(
array(
'actionid' => '3',
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_scale_and_crop',
'data' => array(
'width' => '100%',
'height' => '100%',
),
),
),
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['imagecache_preset'] = array(
array(
'presetid' => '1',
'presetname' => 'slackjaw_boys',
),
);
$this->databaseContents['imagecache_action'] = array(
array(
'actionid' => '3',
'presetid' => '1',
'weight' => '0',
'module' => 'imagecache',
'action' => 'imagecache_scale_and_crop',
'data' => 'a:2:{s:5:"width";s:4:"100%";s:6:"height";s:4:"100%";}',
),
);
parent::setUp();
}
}
<?php
namespace Drupal\Tests\image\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 ImageStyles source plugin.
*
* @group image
*/
class MigrateImageStylesTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\image\Plugin\migrate\source\d7\ImageStyles';
protected $migrationConfiguration = [
'id' => 'test',
'source' => [
'plugin' => 'd7_image_styles',
],
];
protected $expectedResults = [
[
'isid' => 1,
'name' => 'custom_image_style_1',
'label' => 'Custom image style 1',
'effects' => [
[
'ieid' => 1,
'isid' => 1,
'weight' => 1,
'name' => 'image_desaturate',
'data' => [],
]
]
],
];
/**
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
foreach (array('isid', 'name', 'label') as $field) {
$this->databaseContents['image_styles'][$k][$field] = $row[$field];
}
foreach ($row['effects'] as $id => $effect) {
$row['effects'][$id]['data'] = serialize($row['effects'][$id]['data']);
}
$this->databaseContents['image_effects'] = $row['effects'];
}
parent::setUp();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment