diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Config.php b/core/modules/migrate/src/Plugin/migrate/destination/Config.php index 18d78a325e1cde669db74ebbb45c0822d695227e..13f7e908e0b802e56bfa126d7e12a3956b62c89c 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Config.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Config.php @@ -46,7 +46,7 @@ * * @code * source: - * plugin: i18n_variable + * plugin: d6_variable_translation * variables: * - site_offline_message * process: @@ -60,10 +60,10 @@ * * This will add the value of the variable "site_offline_message" to the config * with the machine name "system.maintenance" as "system.maintenance.message", - * coupled with the relevant langcode as obtained from the "i18n_variable" - * source plugin. + * coupled with the relevant langcode as obtained from the + * "d6_variable_translation" source plugin. * - * @see \Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable + * @see \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation * * @MigrateDestination( * id = "config" diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php deleted file mode 100644 index 428c286ef7bb842836d6876ad5bdd416d7060855..0000000000000000000000000000000000000000 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate\Unit; - -use Drupal\Core\Database\Query\SelectInterface; -use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\Core\DependencyInjection\ContainerNotInitializedException; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; - -/** - * Base class for Migrate module source unit tests. - * - * @deprecated in drupal:8.2.0 and is removed from drupal:9.0.0. Use - * \Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase instead. - */ -abstract class MigrateSqlSourceTestCase extends MigrateTestCase { - - /** - * The tested source plugin. - * - * @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase - */ - protected $source; - - /** - * The database contents. - * - * Database contents represents a mocked database. It should contain an - * associative array with the table name as key, and as many nested arrays as - * the number of mocked rows. Each of those faked rows must be another array - * with the column name as the key and the value as the cell. - * - * @var array - */ - protected $databaseContents = []; - - /** - * The plugin class under test. - * - * The plugin system is not working during unit testing so the source plugin - * class needs to be manually specified. - * - * @var string - */ - const PLUGIN_CLASS = ''; - - /** - * The high water mark at the beginning of the import operation. - * - * Once the migration is run, we save a mark of the migrated sources, so the - * migration can run again and update only new sources or changed sources. - * - * @var mixed - */ - const ORIGINAL_HIGH_WATER = NULL; - - /** - * Expected results after the source parsing. - * - * @var array - */ - protected $expectedResults = []; - - /** - * Expected count of source rows. - * - * @var int - */ - protected $expectedCount = 0; - - /** - * The source plugin instance under test. - * - * @var \Drupal\migrate\Plugin\MigrateSourceInterface - */ - protected $plugin; - - /** - * {@inheritdoc} - */ - protected function setUp() { - $module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface'); - $state = $this->createMock('Drupal\Core\State\StateInterface'); - $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); - - // Mock a key-value store to return high-water values. - $key_value = $this->createMock(KeyValueStoreInterface::class); - - // SourcePluginBase does not yet support full dependency injection so we - // need to make sure that \Drupal::keyValue() works as expected by mocking - // the keyvalue service. - $key_value_factory = $this->createMock(KeyValueFactoryInterface::class); - $key_value_factory - ->method('get') - ->with('migrate:high_water') - ->willReturn($key_value); - - try { - $container = \Drupal::getContainer(); - } - catch (ContainerNotInitializedException $e) { - $container = new ContainerBuilder(); - } - $container->set('keyvalue', $key_value_factory); - \Drupal::setContainer($container); - - $migration = $this->getMigration(); - - // Set the high water value. - \Drupal::keyValue('migrate:high_water') - ->expects($this->any()) - ->method('get') - ->willReturn(static::ORIGINAL_HIGH_WATER); - - // Setup the plugin. - $plugin_class = static::PLUGIN_CLASS; - $plugin = new $plugin_class($this->migrationConfiguration['source'], $this->migrationConfiguration['source']['plugin'], [], $migration, $state, $entity_type_manager); - - // Do some reflection to set the database and moduleHandler. - $plugin_reflection = new \ReflectionClass($plugin); - $database_property = $plugin_reflection->getProperty('database'); - $database_property->setAccessible(TRUE); - $module_handler_property = $plugin_reflection->getProperty('moduleHandler'); - $module_handler_property->setAccessible(TRUE); - - // Set the database and the module handler onto our plugin. - $database_property->setValue($plugin, $this->getDatabase($this->databaseContents + ['test_map' => []])); - $module_handler_property->setValue($plugin, $module_handler); - - $plugin->setStringTranslation($this->getStringTranslationStub()); - $migration->expects($this->any()) - ->method('getSourcePlugin') - ->will($this->returnValue($plugin)); - $this->source = $plugin; - $this->expectedCount = count($this->expectedResults); - } - - /** - * Tests that the source returns the same rows as expected. - */ - public function testRetrieval() { - $this->assertInstanceOf(SelectInterface::class, $this->source->query()); - $this->queryResultTest($this->source, $this->expectedResults); - } - - /** - * Tests that the source returns the row count expected. - */ - public function testSourceCount() { - $count = $this->source->count(); - $this->assertTrue(is_numeric($count)); - $this->assertEquals($this->expectedCount, $count); - } - - /** - * Tests the source defines a valid ID. - */ - public function testSourceId() { - $this->assertNotEmpty($this->source->getIds()); - } - - /** - * Gets the value on a row for a given key. - * - * @param \Drupal\migrate\Row $row - * The row identifier. - * @param string $key - * The key identifier. - * - * @return mixed - * The value on a row for a given key. - */ - protected function getValue($row, $key) { - return $row->getSourceProperty($key); - } - -} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php deleted file mode 100644 index 423d09467299e8aed885ddb7e44f8e76945ba487..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace Drupal\migrate_drupal\Plugin\migrate\source\d6; - -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\State\StateInterface; -use Drupal\migrate\Plugin\MigrationInterface; - -/** - * Gets Drupal i18n_variable source from database. - * - * @deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. - * Use \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation. - * - * @see https://www.drupal.org/node/3006487 - * - * @MigrateSource( - * id = "variable_translation", - * source_module = "system", - * ) - */ -class D6VariableTranslation extends VariableTranslation { - - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) { - @trigger_error('The ' . __NAMESPACE__ . '\D6VariableTranslation is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\VariableTranslation. See https://www.drupal.org/node/3006487.', E_USER_DEPRECATED); - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); - } - -} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php deleted file mode 100644 index 140399cc3a7d6e94457e62f0a374d99c3161b443..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -namespace Drupal\migrate_drupal\Plugin\migrate\source\d6; - -@trigger_error('The ' . __NAMESPACE__ . '\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\VariableTranslation', E_USER_DEPRECATED); - -/** - * Drupal i18n_variable source from database. - * - * @MigrateSource( - * id = "i18n_variable", - * source_module = "system", - * ) - * - * @deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use - * \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation instead. - * - * @see https://www.drupal.org/node/2898649 - */ -class i18nVariable extends VariableTranslation {} diff --git a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d6/i18nVariableTest.php b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d6/i18nVariableTest.php deleted file mode 100644 index 26a67adb5c5b9604d3212b9814c0e30fdb10bba7..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d6/i18nVariableTest.php +++ /dev/null @@ -1,89 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d6; - -use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; - -/** - * Tests the variable source plugin. - * - * @covers \Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable - * - * @group migrate_drupal - * @group legacy - */ -class i18nVariableTest extends MigrateSqlSourceTestBase { - - /** - * {@inheritdoc} - */ - public static $modules = ['migrate_drupal']; - - /** - * {@inheritdoc} - * - * @dataProvider providerSource - * @requires extension pdo_sqlite - * @expectedDeprecation The Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation - */ - public function testSource(array $source_data, array $expected_data, $expected_count = NULL, array $configuration = [], $high_water = NULL) { - parent::testSource($source_data, $expected_data, $expected_count, $configuration, $high_water); - } - - /** - * {@inheritdoc} - */ - public function providerSource() { - $tests = []; - - // The source data. - $tests[0]['source_data']['i18n_variable'] = [ - [ - 'name' => 'site_slogan', - 'language' => 'fr', - 'value' => 's:19:"Migrate est génial";', - ], - [ - 'name' => 'site_name', - 'language' => 'fr', - 'value' => 's:11:"nom de site";', - ], - [ - 'name' => 'site_slogan', - 'language' => 'mi', - 'value' => 's:19:"Ko whakamataku heke";', - ], - [ - 'name' => 'site_name', - 'language' => 'mi', - 'value' => 's:9:"ingoa_pae";', - ], - ]; - - // The expected results. - $tests[0]['expected_data'] = [ - [ - 'language' => 'fr', - 'site_slogan' => 'Migrate est génial', - 'site_name' => 'nom de site', - ], - [ - 'language' => 'mi', - 'site_slogan' => 'Ko whakamataku heke', - 'site_name' => 'ingoa_pae', - ], - ]; - - // The expected count. - $tests[0]['expected_count'] = NULL; - - // The migration configuration. - $tests[0]['configuration']['variables'] = [ - 'site_slogan', - 'site_name', - ]; - - return $tests; - } - -} diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php b/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php deleted file mode 100644 index 5710436221dc4d8f484785960aa5314e7532644a..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate_drupal\Unit\source; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Base class for variable multirow source unit tests. - */ -abstract class VariableMultiRowTestBase extends MigrateSqlSourceTestCase { - - // The plugin system is not working during unit testing so the source plugin - // class needs to be manually specified. - const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow'; - - // The fake Migration configuration entity. - protected $migrationConfiguration = [ - 'id' => 'test', - 'source' => [ - 'plugin' => 'd6_variable_multirow', - 'variables' => [ - 'foo', - 'bar', - ], - ], - ]; - - protected $expectedResults = [ - ['name' => 'foo', 'value' => 1], - ['name' => 'bar', 'value' => FALSE], - ]; - - protected $databaseContents = [ - 'variable' => [ - ['name' => 'foo', 'value' => 'i:1;'], - ['name' => 'bar', 'value' => 'b:0;'], - ], - ]; - -} diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php deleted file mode 100644 index 1b5abc36b01c84ccb7747ef03f7707aa2301b3c2..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate_drupal\Unit\source; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests the variable source plugin. - * - * @group migrate_drupal - */ -class VariableTest extends MigrateSqlSourceTestCase { - - const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\Variable'; - - protected $migrationConfiguration = [ - 'id' => 'test', - 'highWaterProperty' => ['field' => 'test'], - 'source' => [ - 'plugin' => 'd6_variable', - 'variables' => [ - 'foo', - 'bar', - ], - ], - ]; - - protected $expectedResults = [ - [ - 'id' => 'foo', - 'foo' => 1, - 'bar' => FALSE, - ], - ]; - - protected $databaseContents = [ - 'variable' => [ - ['name' => 'foo', 'value' => 'i:1;'], - ['name' => 'bar', 'value' => 'b:0;'], - ], - ]; - -} diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/VariableTranslationTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/VariableTranslationTest.php deleted file mode 100644 index 4b548923d29b5ab67a4caa2af6664be8d7bbdc3f..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/VariableTranslationTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate_drupal\Unit\source\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests the variable source plugin. - * - * @group migrate_drupal - * @group legacy - */ -class VariableTranslationTest extends MigrateSqlSourceTestCase { - - // The plugin system is not working during unit testing so the source plugin - // class needs to be manually specified. - const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation'; - - /** - * Define bare minimum migration configuration. - */ - protected $migrationConfiguration = [ - 'id' => 'test', - 'highWaterProperty' => ['field' => 'test'], - 'source' => [ - 'plugin' => 'variable_translation', - 'variables' => [ - 'site_slogan', - 'site_name', - ], - ], - ]; - - /** - * Expected results from the source. - */ - protected $expectedResults = [ - [ - 'language' => 'fr', - 'site_slogan' => 'Migrate est génial', - 'site_name' => 'nom de site', - ], - [ - 'language' => 'mi', - 'site_slogan' => 'Ko whakamataku heke', - 'site_name' => 'ingoa_pae', - ], - ]; - - /** - * Database contents for tests. - */ - protected $databaseContents = [ - 'i18n_variable' => [ - ['name' => 'site_slogan', 'language' => 'fr', 'value' => 's:19:"Migrate est génial";'], - ['name' => 'site_name', 'language' => 'fr', 'value' => 's:11:"nom de site";'], - ['name' => 'site_slogan', 'language' => 'mi', 'value' => 's:19:"Ko whakamataku heke";'], - ['name' => 'site_name', 'language' => 'mi', 'value' => 's:9:"ingoa_pae";'], - ], - ]; - -} diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php deleted file mode 100644 index d2a15666d1f2b8e366f2e10578a49ecc8f5380e6..0000000000000000000000000000000000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -namespace Drupal\Tests\migrate_drupal\Unit\source\d6; - -use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; - -/** - * Tests the variable source plugin. - * - * @group migrate_drupal - * @group legacy - */ -class i18nVariableTest extends MigrateSqlSourceTestCase { - - // The plugin system is not working during unit testing so the source plugin - // class needs to be manually specified. - const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable'; - - /** - * Define bare minimum migration configuration. - */ - protected $migrationConfiguration = [ - 'id' => 'test', - 'highWaterProperty' => ['field' => 'test'], - 'source' => [ - 'plugin' => 'i18n_variable', - 'variables' => [ - 'site_slogan', - 'site_name', - ], - ], - ]; - - /** - * Expected results from the source. - */ - protected $expectedResults = [ - [ - 'language' => 'fr', - 'site_slogan' => 'Migrate est génial', - 'site_name' => 'nom de site', - ], - [ - 'language' => 'mi', - 'site_slogan' => 'Ko whakamataku heke', - 'site_name' => 'ingoa_pae', - ], - ]; - - /** - * Database contents for tests. - */ - protected $databaseContents = [ - 'i18n_variable' => [ - ['name' => 'site_slogan', 'language' => 'fr', 'value' => 's:19:"Migrate est génial";'], - ['name' => 'site_name', 'language' => 'fr', 'value' => 's:11:"nom de site";'], - ['name' => 'site_slogan', 'language' => 'mi', 'value' => 's:19:"Ko whakamataku heke";'], - ['name' => 'site_name', 'language' => 'mi', 'value' => 's:9:"ingoa_pae";'], - ], - ]; - -}