Commit 8f7a0d63 authored by alexpott's avatar alexpott

Issue #2624914 by Lars Toomre: Fixes to migrate/src/Tests/*.php files

parent e420d221
......@@ -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.
......
......@@ -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();
......
......@@ -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);
......
......@@ -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
*/
......
......@@ -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'],
......
......@@ -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);
......
......@@ -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.
......
......@@ -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)) {
......
......@@ -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()
*/
......
......@@ -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.
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment