From f6b32fd0d2ca86a1a69d96fef34d90390222d7d4 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 23 Dec 2015 18:08:05 +0100 Subject: [PATCH] Issue #2624914 by Lars Toomre: Fixes to migrate/src/Tests/*.php files (cherry picked from commit 8f7a0d633f9b86a30fcbb5facc753090da71a441) --- .../src/Tests/MigrateDumpAlterInterface.php | 5 +- .../migrate/src/Tests/MigrateEventsTest.php | 2 +- .../src/Tests/MigrateInterruptionTest.php | 5 +- .../migrate/src/Tests/MigrateMessageTest.php | 2 +- .../migrate/src/Tests/MigrateRollbackTest.php | 4 +- .../migrate/src/Tests/MigrateSkipRowTest.php | 4 +- .../migrate/src/Tests/MigrateStatusTest.php | 4 +- .../migrate/src/Tests/MigrateTestBase.php | 12 +++-- .../migrate/src/Tests/MigrationTest.php | 4 +- .../modules/migrate/src/Tests/SqlBaseTest.php | 14 ++--- .../migrate/src/Tests/TemplateTest.php | 52 +++++++++---------- 11 files changed, 55 insertions(+), 53 deletions(-) diff --git a/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php b/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php index 94b8a3de8bcf..3f2265772d66 100644 --- a/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php +++ b/core/modules/migrate/src/Tests/MigrateDumpAlterInterface.php @@ -10,15 +10,14 @@ use Drupal\simpletest\TestBase; /** - * Allows tests to alter dumps after they've loaded. + * Allows tests to alter dumps after they have loaded. * - * @s * @see \Drupal\migrate_drupal\Tests\d6\MigrateFileTest */ interface MigrateDumpAlterInterface { /** - * Allows tests to alter dumps after they've loaded. + * Allows tests to alter dumps after they have loaded. * * @param \Drupal\simpletest\TestBase $test * The test that is being run. diff --git a/core/modules/migrate/src/Tests/MigrateEventsTest.php b/core/modules/migrate/src/Tests/MigrateEventsTest.php index ccc82acd3fbc..ae540ac46a4b 100644 --- a/core/modules/migrate/src/Tests/MigrateEventsTest.php +++ b/core/modules/migrate/src/Tests/MigrateEventsTest.php @@ -85,7 +85,7 @@ public function testMigrateEvents() { $migration = Migration::create($config); /** @var MigrationInterface $migration */ - $executable = new MigrateExecutable($migration, new MigrateMessage); + $executable = new MigrateExecutable($migration, new MigrateMessage()); // As the import runs, events will be dispatched, recording the received // information in state. $executable->import(); diff --git a/core/modules/migrate/src/Tests/MigrateInterruptionTest.php b/core/modules/migrate/src/Tests/MigrateInterruptionTest.php index 3ffd22b817f7..a7abd86d23b7 100644 --- a/core/modules/migrate/src/Tests/MigrateInterruptionTest.php +++ b/core/modules/migrate/src/Tests/MigrateInterruptionTest.php @@ -64,8 +64,9 @@ public function testMigrateEvents() { $migration = Migration::create($config); /** @var MigrationInterface $migration */ - $executable = new MigrateExecutable($migration, new MigrateMessage); - // When the import runs, the first row imported will trigger an interruption. + $executable = new MigrateExecutable($migration, new MigrateMessage()); + // When the import runs, the first row imported will trigger an + // interruption. $result = $executable->import(); $this->assertEqual($result, MigrationInterface::RESULT_INCOMPLETE); diff --git a/core/modules/migrate/src/Tests/MigrateMessageTest.php b/core/modules/migrate/src/Tests/MigrateMessageTest.php index 7345c53063d5..dcf2a8b04f97 100644 --- a/core/modules/migrate/src/Tests/MigrateMessageTest.php +++ b/core/modules/migrate/src/Tests/MigrateMessageTest.php @@ -16,7 +16,7 @@ use Drupal\simpletest\KernelTestBase; /** - * Test whether idmap messages are sent to the message interface when requested. + * Tests whether idmap messages are sent to message interface when requested. * * @group migrate */ diff --git a/core/modules/migrate/src/Tests/MigrateRollbackTest.php b/core/modules/migrate/src/Tests/MigrateRollbackTest.php index ec03bb1aef8f..9d6055c84ea9 100644 --- a/core/modules/migrate/src/Tests/MigrateRollbackTest.php +++ b/core/modules/migrate/src/Tests/MigrateRollbackTest.php @@ -81,8 +81,8 @@ public function testRollback() { $this->assertNotNull($map_row['destid1']); } - // We use taxonomy terms to demonstrate importing and rolling back - // content entities. + // We use taxonomy terms to demonstrate importing and rolling back content + // entities. $term_data_rows = [ ['id' => '1', 'vocab' => '1', 'name' => 'music'], ['id' => '2', 'vocab' => '2', 'name' => 'Bach'], diff --git a/core/modules/migrate/src/Tests/MigrateSkipRowTest.php b/core/modules/migrate/src/Tests/MigrateSkipRowTest.php index d27a9aedb191..93c1a7c1491a 100644 --- a/core/modules/migrate/src/Tests/MigrateSkipRowTest.php +++ b/core/modules/migrate/src/Tests/MigrateSkipRowTest.php @@ -41,7 +41,7 @@ public function testPrepareRowSkip() { 'plugin' => 'embedded_data', 'data_rows' => [ ['id' => '1', 'data' => 'skip_and_record'], - ['id' => '2', 'data' => 'skip_and_dont_record'] + ['id' => '2', 'data' => 'skip_and_dont_record'], ], 'ids' => [ 'id' => ['type' => 'string'], @@ -57,7 +57,7 @@ public function testPrepareRowSkip() { $migration = Migration::create($config); - $executable = new MigrateExecutable($migration, new MigrateMessage); + $executable = new MigrateExecutable($migration, new MigrateMessage()); $result = $executable->import(); $this->assertEqual($result, MigrationInterface::RESULT_COMPLETED); diff --git a/core/modules/migrate/src/Tests/MigrateStatusTest.php b/core/modules/migrate/src/Tests/MigrateStatusTest.php index 17b12e7949ea..bdfcf7446b9b 100644 --- a/core/modules/migrate/src/Tests/MigrateStatusTest.php +++ b/core/modules/migrate/src/Tests/MigrateStatusTest.php @@ -11,14 +11,14 @@ use Drupal\migrate\Entity\MigrationInterface; /** - * Test migration status tracking. + * Tests migration status tracking. * * @group migrate */ class MigrateStatusTest extends MigrateTestBase { /** - * Test different connection types. + * Tests different connection types. */ public function testStatus() { // Create a minimally valid migration. diff --git a/core/modules/migrate/src/Tests/MigrateTestBase.php b/core/modules/migrate/src/Tests/MigrateTestBase.php index d8e4bbdbd7b2..e9012e34e914 100644 --- a/core/modules/migrate/src/Tests/MigrateTestBase.php +++ b/core/modules/migrate/src/Tests/MigrateTestBase.php @@ -16,7 +16,7 @@ use Drupal\simpletest\KernelTestBase; /** - * Base class for migration tests. + * Creates abstract base class for migration tests. */ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageInterface { @@ -146,7 +146,7 @@ protected function prepareMigrations(array $id_mappings) { * Executes a single migration. * * @param string|\Drupal\migrate\Entity\MigrationInterface $migration - * The migration to execute, or its ID. + * The migration to execute, or its ID. */ protected function executeMigration($migration) { if (is_string($migration)) { @@ -200,8 +200,9 @@ public function stopCollectingMessages() { } /** - * Records a failure in the map table of a specific migration in order to - * test scenarios which require a failed row. + * Records a failure in the map table of a specific migration. + * + * This is done in order to test scenarios which require a failed row. * * @param string|\Drupal\migrate\Entity\MigrationInterface $migration * The migration entity, or its ID. @@ -209,7 +210,8 @@ public function stopCollectingMessages() { * The raw source row which "failed". * @param int $status * (optional) The failure status. Should be one of the - * MigrateIdMapInterface::STATUS_* constants. + * MigrateIdMapInterface::STATUS_* constants. Defaults to + * MigrateIdMapInterface::STATUS_FAILED. */ protected function mockFailure($migration, array $row, $status = MigrateIdMapInterface::STATUS_FAILED) { if (is_string($migration)) { diff --git a/core/modules/migrate/src/Tests/MigrationTest.php b/core/modules/migrate/src/Tests/MigrationTest.php index 96dfadab1c77..6511903b7b90 100644 --- a/core/modules/migrate/src/Tests/MigrationTest.php +++ b/core/modules/migrate/src/Tests/MigrationTest.php @@ -19,14 +19,14 @@ class MigrationTest extends KernelTestBase { /** - * Enable field because we're using one of its source plugins. + * Enable field because we are using one of its source plugins. * * @var array */ public static $modules = ['migrate', 'field']; /** - * Tests Migration::set() + * Tests Migration::set(). * * @covers ::set() */ diff --git a/core/modules/migrate/src/Tests/SqlBaseTest.php b/core/modules/migrate/src/Tests/SqlBaseTest.php index 0ac7bcae0414..0fd15a66c27b 100644 --- a/core/modules/migrate/src/Tests/SqlBaseTest.php +++ b/core/modules/migrate/src/Tests/SqlBaseTest.php @@ -11,14 +11,14 @@ use Drupal\Core\Database\Database; /** - * Test the functionality of SqlBase. + * Tests the functionality of SqlBase. * * @group migrate */ class SqlBaseTest extends MigrateTestBase { /** - * Test different connection types. + * Tests different connection types. */ public function testConnectionTypes() { $sql_base = new TestSqlBase(); @@ -34,7 +34,7 @@ public function testConnectionTypes() { $sql_base->setConfiguration($config); Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']); - // Validate we've injected our custom key and target. + // Validate we have injected our custom key and target. $this->assertIdentical($sql_base->getDatabase()->getTarget(), $target); $this->assertIdentical($sql_base->getDatabase()->getKey(), $key); @@ -62,7 +62,7 @@ public function testConnectionTypes() { $sql_base->setConfiguration(['database_state_key' => $database_state_key]); Database::addConnectionInfo($key, $target, Database::getConnectionInfo('default')['default']); - // Validate we've injected our custom key and target. + // Validate we have injected our custom key and target. $this->assertIdentical($sql_base->getDatabase()->getTarget(), $target); $this->assertIdentical($sql_base->getDatabase()->getKey(), $key); @@ -96,14 +96,14 @@ public function testConnectionTypes() { class TestSqlBase extends SqlBase { /** - * Override the constructor so we can create one easily. + * Overrides the constructor so we can create one easily. */ public function __construct() { $this->state = \Drupal::state(); } /** - * Get the database without caching it. + * Gets the database without caching it. */ public function getDatabase() { $this->database = NULL; @@ -111,7 +111,7 @@ public function getDatabase() { } /** - * Allow us to set the configuration from a test. + * Allows us to set the configuration from a test. * * @param array $config * The config array. diff --git a/core/modules/migrate/src/Tests/TemplateTest.php b/core/modules/migrate/src/Tests/TemplateTest.php index f98d807ee3b6..44400e98154a 100644 --- a/core/modules/migrate/src/Tests/TemplateTest.php +++ b/core/modules/migrate/src/Tests/TemplateTest.php @@ -8,7 +8,7 @@ namespace Drupal\migrate\Tests; /** - * Test the migration template functionality. + * Tests the migration template functionality. * * @group migrate */ @@ -22,25 +22,25 @@ class TemplateTest extends MigrateTestBase { public static $modules = array('template_test'); /** - * Test different connection types. + * Tests different connection types. */ public function testTemplates() { $migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag("Template Test"); $expected_url = [ - 'id' => 'url_template', - 'label' => 'Template test - url', - 'migration_tags' => ['Template Test'], - 'source' => ['plugin' => 'empty'], - 'process' => ['src' => 'foobar'], - 'destination' => ['plugin' => 'url_alias'], + 'id' => 'url_template', + 'label' => 'Template test - url', + 'migration_tags' => ['Template Test'], + 'source' => ['plugin' => 'empty'], + 'process' => ['src' => 'foobar'], + 'destination' => ['plugin' => 'url_alias'], ]; $expected_node = [ - 'id' => 'node_template', - 'label' => 'Template test - node', - 'migration_tags' => ['Template Test'], - 'source' => ['plugin' => 'empty'], - 'process' => ['src' => 'barfoo'], - 'destination' => ['plugin' => 'entity:node'], + 'id' => 'node_template', + 'label' => 'Template test - node', + 'migration_tags' => ['Template Test'], + 'source' => ['plugin' => 'empty'], + 'process' => ['src' => 'barfoo'], + 'destination' => ['plugin' => 'entity:node'], ]; $this->assertIdentical($migration_templates['migrate.migration.url_template'], $expected_url); $this->assertIdentical($migration_templates['migrate.migration.node_template'], $expected_node); @@ -55,20 +55,20 @@ public function testGetTemplateByName() { $template_storage = \Drupal::service('migrate.template_storage'); $expected_url = [ - 'id' => 'url_template', - 'label' => 'Template test - url', - 'migration_tags' => ['Template Test'], - 'source' => ['plugin' => 'empty'], - 'process' => ['src' => 'foobar'], - 'destination' => ['plugin' => 'url_alias'], + 'id' => 'url_template', + 'label' => 'Template test - url', + 'migration_tags' => ['Template Test'], + 'source' => ['plugin' => 'empty'], + 'process' => ['src' => 'foobar'], + 'destination' => ['plugin' => 'url_alias'], ]; $expected_node = [ - 'id' => 'node_template', - 'label' => 'Template test - node', - 'migration_tags' => ['Template Test'], - 'source' => ['plugin' => 'empty'], - 'process' => ['src' => 'barfoo'], - 'destination' => ['plugin' => 'entity:node'], + 'id' => 'node_template', + 'label' => 'Template test - node', + 'migration_tags' => ['Template Test'], + 'source' => ['plugin' => 'empty'], + 'process' => ['src' => 'barfoo'], + 'destination' => ['plugin' => 'entity:node'], ]; $this->assertIdentical($template_storage->getTemplateByName('migrate.migration.url_template'), $expected_url); $this->assertIdentical($template_storage->getTemplateByName('migrate.migration.node_template'), $expected_node); -- GitLab