From 7f4e7eb6786e99425894556655950ace08b1bc3a Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sat, 15 Oct 2016 06:36:26 +0100 Subject: [PATCH] Issue #2807893 by svendecabooter: Convert Image's Migrate source tests to new base class --- .../source/d6/ImageCachePresetTest.php | 69 +++++++++++++++++++ .../migrate/source/d7/ImageStylesTest.php | 66 ++++++++++++++++++ .../source/d6/ImageCachePresetTest.php | 67 ------------------ .../source/d7/MigrateImageStylesTest.php | 56 --------------- 4 files changed, 135 insertions(+), 123 deletions(-) create mode 100644 core/modules/image/tests/src/Kernel/Plugin/migrate/source/d6/ImageCachePresetTest.php create mode 100644 core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php delete mode 100644 core/modules/image/tests/src/Unit/Plugin/migrate/source/d6/ImageCachePresetTest.php delete mode 100644 core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php diff --git a/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d6/ImageCachePresetTest.php b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d6/ImageCachePresetTest.php new file mode 100644 index 000000000000..edd2ad335841 --- /dev/null +++ b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d6/ImageCachePresetTest.php @@ -0,0 +1,69 @@ +<?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; + } + +} diff --git a/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php new file mode 100644 index 000000000000..bb91de8a939b --- /dev/null +++ b/core/modules/image/tests/src/Kernel/Plugin/migrate/source/d7/ImageStylesTest.php @@ -0,0 +1,66 @@ +<?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; + } + +} diff --git a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d6/ImageCachePresetTest.php b/core/modules/image/tests/src/Unit/Plugin/migrate/source/d6/ImageCachePresetTest.php deleted file mode 100644 index 7d42e8a07124..000000000000 --- a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d6/ImageCachePresetTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?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(); - } - -} diff --git a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php b/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php deleted file mode 100644 index 3c3a8cc8593d..000000000000 --- a/core/modules/image/tests/src/Unit/Plugin/migrate/source/d7/MigrateImageStylesTest.php +++ /dev/null @@ -1,56 +0,0 @@ -<?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(); - } - -} -- GitLab