From eb9af30a4231c57fc2e11066d5eda73118738d48 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 28 Jan 2020 09:27:16 +0000 Subject: [PATCH] Issue #3096991 by quietone, alexpott, Wim Leers: Remove deprecated MigrateSqlSourceTestCase --- .../src/Plugin/migrate/destination/Config.php | 8 +- .../src/Unit/MigrateSqlSourceTestCase.php | 179 ------------------ .../source/d6/D6VariableTranslation.php | 32 ---- .../Plugin/migrate/source/d6/i18nVariable.php | 20 -- .../migrate/source/d6/i18nVariableTest.php | 89 --------- .../Unit/source/VariableMultiRowTestBase.php | 40 ---- .../tests/src/Unit/source/VariableTest.php | 43 ----- .../source/d6/VariableTranslationTest.php | 62 ------ .../src/Unit/source/d6/i18nVariableTest.php | 62 ------ 9 files changed, 4 insertions(+), 531 deletions(-) delete mode 100644 core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php delete mode 100644 core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php delete mode 100644 core/modules/migrate_drupal/src/Plugin/migrate/source/d6/i18nVariable.php delete mode 100644 core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/d6/i18nVariableTest.php delete mode 100644 core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php delete mode 100644 core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php delete mode 100644 core/modules/migrate_drupal/tests/src/Unit/source/d6/VariableTranslationTest.php delete mode 100644 core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Config.php b/core/modules/migrate/src/Plugin/migrate/destination/Config.php index 18d78a325e1..13f7e908e0b 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 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @code * source: - * plugin: i18n_variable + * plugin: d6_variable_translation * variables: * - site_offline_message * process: @@ -60,10 +60,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * 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 428c286ef7b..00000000000 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlSourceTestCase.php +++ /dev/null @@ -1,179 +0,0 @@ -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 423d0946729..00000000000 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/D6VariableTranslation.php +++ /dev/null @@ -1,32 +0,0 @@ - '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 5710436221d..00000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableMultiRowTestBase.php +++ /dev/null @@ -1,40 +0,0 @@ - '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 1b5abc36b01..00000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/VariableTest.php +++ /dev/null @@ -1,43 +0,0 @@ - '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 4b548923d29..00000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/VariableTranslationTest.php +++ /dev/null @@ -1,62 +0,0 @@ - '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 d2a15666d1f..00000000000 --- a/core/modules/migrate_drupal/tests/src/Unit/source/d6/i18nVariableTest.php +++ /dev/null @@ -1,62 +0,0 @@ - '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";'], - ], - ]; - -}