diff --git a/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d6/FilterFormatTest.php b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d6/FilterFormatTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a3e708b7b9a8dcf27cbb059f02cb8fd28321ab0e --- /dev/null +++ b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d6/FilterFormatTest.php @@ -0,0 +1,174 @@ +<?php + +namespace Drupal\Tests\filter\Kernel\Plugin\migrate\source\d6; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests D6 filter format source plugin. + * + * @covers \Drupal\filter\Plugin\migrate\source\d6\FilterFormat + * + * @group filter + */ +class FilterFormatTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['filter', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['filter_formats'] = [ + [ + 'format' => 1, + 'name' => 'Filtered HTML', + 'roles' => ',1,2,', + 'cache' => 1, + ], + [ + 'format' => 2, + 'name' => 'Full HTML', + 'roles' => '', + 'cache' => 1, + ], + [ + 'format' => 4, + 'name' => 'Example Custom Format', + 'roles' => '4', + 'cache' => 1, + ], + ]; + $tests[0]['source_data']['filters'] = [ + [ + 'fid' => 1, + 'format' => 1, + 'module' => 'filter', + 'delta' => 2, + 'weight' => 0, + ], + [ + 'fid' => 2, + 'format' => 1, + 'module' => 'filter', + 'delta' => 0, + 'weight' => 1, + ], + [ + 'fid' => 3, + 'format' => 1, + 'module' => 'filter', + 'delta' => 1, + 'weight' => 2, + ], + [ + 'fid' => 4, + 'format' => 2, + 'module' => 'filter', + 'delta' => 2, + 'weight' => 0, + ], + [ + 'fid' => 5, + 'format' => 2, + 'module' => 'filter', + 'delta' => 1, + 'weight' => 1, + ], + [ + 'fid' => 6, + 'format' => 2, + 'module' => 'filter', + 'delta' => 3, + 'weight' => 10, + ], + [ + 'fid' => 7, + 'format' => 4, + 'module' => 'markdown', + 'delta' => 1, + 'weight' => 10, + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'format' => 1, + 'name' => 'Filtered HTML', + 'roles' => [1, 2], + 'cache' => 1, + 'filters' => [ + [ + 'module' => 'filter', + 'delta' => 2, + 'weight' => 0, + 'settings' => [], + ], + [ + 'module' => 'filter', + 'delta' => 0, + 'weight' => 1, + 'settings' => [], + ], + [ + 'module' => 'filter', + 'delta' => 1, + 'weight' => 2, + 'settings' => [], + ], + ], + ], + [ + 'format' => 2, + 'name' => 'Full HTML', + 'roles' => [], + 'cache' => 1, + 'filters' => [ + [ + 'module' => 'filter', + 'delta' => 2, + 'weight' => 0, + 'settings' => [], + ], + [ + 'module' => 'filter', + 'delta' => 1, + 'weight' => 1, + 'settings' => [], + ], + [ + 'module' => 'filter', + 'delta' => 3, + 'weight' => 10, + 'settings' => [], + ], + ], + ], + [ + 'format' => 4, + 'name' => 'Example Custom Format', + 'roles' => [4], + 'cache' => 1, + 'filters' => [ + // This custom format uses a filter defined by a contrib module. + [ + 'module' => 'markdown', + 'delta' => 1, + 'weight' => 10, + 'settings' => [], + ], + ], + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f68b93579319830d32aa2daf57740059e19e39f1 --- /dev/null +++ b/core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php @@ -0,0 +1,120 @@ +<?php + +namespace Drupal\Tests\filter\Kernel\Plugin\migrate\source\d7; + +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; + +/** + * Tests D7 filter format source plugin. + * + * @covers \Drupal\filter\Plugin\migrate\source\d7\FilterFormat + * + * @group filter + */ +class FilterFormatTest extends MigrateSqlSourceTestBase { + + /** + * {@inheritdoc} + */ + public static $modules = ['filter', 'migrate_drupal']; + + /** + * {@inheritdoc} + */ + public function providerSource() { + $tests = []; + + // The source data. + $tests[0]['source_data']['filter_format'] = [ + [ + 'format' => 'custom_text_format', + 'name' => 'Custom Text format', + 'cache' => 1, + 'status' => 1, + 'weight' => 0, + ], + [ + 'format' => 'full_html', + 'name' => 'Full HTML', + 'cache' => 1, + 'status' => 1, + 'weight' => 1, + ], + ]; + $tests[0]['source_data']['filter'] = [ + [ + 'format' => 'custom_text_format', + 'module' => 'filter', + 'name' => 'filter_autop', + 'weight' => 0, + 'status' => 1, + 'settings' => serialize(array()), + ], + [ + 'format' => 'custom_text_format', + 'module' => 'filter', + 'name' => 'filter_html', + 'weight' => 1, + 'status' => 1, + 'settings' => serialize(array()), + ], + [ + 'format' => 'full_html', + 'module' => 'filter', + 'name' => 'filter_url', + 'weight' => 0, + 'status' => 1, + 'settings' => serialize(array()), + ], + ]; + + // The expected results. + $tests[0]['expected_data'] = [ + [ + 'format' => 'custom_text_format', + 'name' => 'Custom Text format', + 'cache' => 1, + 'status' => 1, + 'weight' => 0, + 'filters' => [ + 'filter_autop' => [ + 'format' => 'custom_text_format', + 'module' => 'filter', + 'name' => 'filter_autop', + 'weight' => 0, + 'status' => 1, + 'settings' => [], + ], + 'filter_html' => [ + 'format' => 'custom_text_format', + 'module' => 'filter', + 'name' => 'filter_html', + 'weight' => 1, + 'status' => 1, + 'settings' => [], + ], + ], + ], + [ + 'format' => 'full_html', + 'name' => 'Full HTML', + 'cache' => 1, + 'status' => 1, + 'weight' => 1, + 'filters' => [ + 'filter_url' => [ + 'format' => 'full_html', + 'module' => 'filter', + 'name' => 'filter_url', + 'weight' => 0, + 'status' => 1, + 'settings' => [], + ], + ], + ], + ]; + + return $tests; + } + +} diff --git a/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d6/FilterFormatTest.php b/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d6/FilterFormatTest.php deleted file mode 100644 index 6b28613215e923ddfa0e8da00908553898dc0fe4..0000000000000000000000000000000000000000 --- a/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d6/FilterFormatTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -namespace Drupal\Tests\filter\Unit\Plugin\migrate\source\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests d6_filter_format source plugin. - * - * @group filter - */ -class FilterFormatTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\filter\Plugin\migrate\source\d6\FilterFormat'; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_filter_formats', - ), - ); - - protected $expectedResults = array( - array( - 'format' => 1, - 'name' => 'Filtered HTML', - 'roles' => array(1, 2), - 'cache' => 1, - 'filters' => array( - array( - 'module' => 'filter', - 'delta' => 2, - 'weight' => 0, - 'settings' => array(), - ), - array( - 'module' => 'filter', - 'delta' => 0, - 'weight' => 1, - 'settings' => array(), - ), - array( - 'module' => 'filter', - 'delta' => 1, - 'weight' => 2, - 'settings' => array(), - ), - ), - ), - array( - 'format' => 2, - 'name' => 'Full HTML', - 'roles' => array(), - 'cache' => 1, - 'filters' => array( - array( - 'module' => 'filter', - 'delta' => 2, - 'weight' => 0, - 'settings' => array(), - ), - array( - 'module' => 'filter', - 'delta' => 1, - 'weight' => 1, - 'settings' => array(), - ), - array( - 'module' => 'filter', - 'delta' => 3, - 'weight' => 10, - 'settings' => array(), - ), - ), - ), - array( - 'format' => 4, - 'name' => 'Example Custom Format', - 'roles' => array(4), - 'cache' => 1, - 'filters' => array( - // This custom format uses a filter defined by a contrib module. - array( - 'module' => 'markdown', - 'delta' => 1, - 'weight' => 10, - 'settings' => array(), - ), - ), - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - $fid = 1; - $empty_array = serialize(array()); - foreach ($this->expectedResults as $k => $row) { - $row['roles'] = ',' . implode(',', $row['roles']) . ','; - foreach ($row['filters'] as $filter) { - $filter['settings'] = $empty_array; - $this->databaseContents['filters'][$fid] = $filter; - $this->databaseContents['filters'][$fid]['format'] = $row['format']; - $this->databaseContents['filters'][$fid]['fid'] = $fid; - $fid++; - } - unset($row['filters']); - $this->databaseContents['filter_formats'][$k] = $row; - } - parent::setUp(); - } - -} diff --git a/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d7/FilterFormatTest.php b/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d7/FilterFormatTest.php deleted file mode 100644 index 2616ad1c9b8eaad38df79064dac90a83aa83d111..0000000000000000000000000000000000000000 --- a/core/modules/filter/tests/src/Unit/Plugin/migrate/source/d7/FilterFormatTest.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php - -namespace Drupal\Tests\filter\Unit\Plugin\migrate\source\d7; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests d7_filter_format source plugin. - * - * @group filter - */ -class FilterFormatTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\filter\Plugin\migrate\source\d7\FilterFormat'; - - protected $migrationConfiguration = array( - 'id' => 'test', - 'source' => array( - 'plugin' => 'd6_filter_formats', - ), - ); - - protected $expectedResults = array( - array( - 'format' => 'custom_text_format', - 'name' => 'Custom Text format', - 'cache' => 1, - 'status' => 1, - 'weight' => 0, - 'filters' => array( - 'filter_autop' => array( - 'format' => 'custom_text_format', - 'module' => 'filter', - 'name' => 'filter_autop', - 'weight' => 0, - 'status' => 1, - 'settings' => array(), - ), - 'filter_html' => array( - 'format' => 'custom_text_format', - 'module' => 'filter', - 'name' => 'filter_html', - 'weight' => 1, - 'status' => 1, - 'settings' => array(), - ), - ), - ), - array( - 'format' => 'full_html', - 'name' => 'Full HTML', - 'cache' => 1, - 'status' => 1, - 'weight' => 1, - 'filters' => array( - 'filter_url' => array( - 'format' => 'full_html', - 'module' => 'filter', - 'name' => 'filter_url', - 'weight' => 0, - 'status' => 1, - 'settings' => array(), - ), - ), - ), - ); - - /** - * {@inheritdoc} - */ - protected function setUp() { - foreach ($this->expectedResults as $row) { - foreach ($row['filters'] as $filter) { - $filter['format'] = $row['format']; - $filter['settings'] = serialize($filter['settings']); - $this->databaseContents['filter'][] = $filter; - } - unset($row['filters']); - $this->databaseContents['filter_format'][] = $row; - } - parent::setUp(); - } - -}