summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-08-23 17:26:56 (GMT)
committerAlex Pott2016-08-23 17:26:56 (GMT)
commit7d6e615f1e2f778aa4d811983d32ca6248e9b417 (patch)
tree7cc6842e54bf309c65dbbcf659b7d7d6fa654a8a
parent1ba97fcf577de9508e3ff2081e43c16032bc1fd3 (diff)
Issue #2549801 by quietone, balagan, lostkangaroo, pingers, martins.kajins, phenaproxima, scuba_fly, penyaskito: Improve source provider missing exception message
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php2
-rw-r--r--core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php102
2 files changed, 103 insertions, 1 deletions
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
index 8c70551..87bd66d 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
@@ -102,7 +102,7 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
}
}
else {
- throw new RequirementsException('Missing source provider ' . $this->pluginDefinition['source_provider'], ['source_provider' => $this->pluginDefinition['source_provider']]);
+ throw new RequirementsException('The module ' . $this->pluginDefinition['source_provider'] . ' is not enabled in the source site.');
}
}
}
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
new file mode 100644
index 0000000..f603afa
--- /dev/null
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
@@ -0,0 +1,102 @@
+<?php
+
+namespace Drupal\Tests\migrate_drupal\Unit\source;
+
+use Drupal\Tests\migrate\Unit\MigrateTestCase;
+use Drupal\migrate\Exception\RequirementsException;
+
+/**
+ * @coversDefaultClass Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
+ * @group migrate_drupal
+ */
+class DrupalSqlBaseTest extends MigrateTestCase {
+
+ /**
+ * Define bare minimum migration configuration.
+ */
+ protected $migrationConfiguration = array(
+ 'id' => 'DrupalSqlBase',
+ );
+
+ /**
+ * @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
+ */
+ protected $base;
+
+ /**
+ * Minimum database contents needed to test DrupalSqlBase.
+ */
+ protected $databaseContents = array(
+ 'system' => array(
+ array(
+ 'filename' => 'sites/all/modules/module1',
+ 'name' => 'module1',
+ 'type' => 'module',
+ 'status' => 0,
+ 'schema_version' => -1,
+ ),
+ ),
+ );
+
+ /**
+ * @covers ::checkRequirements
+ */
+ public function testSourceProviderNotActive() {
+ $this->setExpectedException(RequirementsException::class, 'The module module1 is not enabled in the source site.');
+ $plugin_definition['requirements_met'] = TRUE;
+ $plugin_definition['source_provider'] = 'module1';
+ /** @var \Drupal\Core\State\StateInterface $state */
+ $state = $this->getMock('Drupal\Core\State\StateInterface');
+ /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
+ $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
+ $plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this->getMigration(), $state, $entity_manager);
+ $plugin->setDatabase($this->getDatabase($this->databaseContents));
+ $system_data = $plugin->getSystemData();
+ $plugin->checkRequirements();
+ }
+
+}
+
+namespace Drupal\Tests\migrate_drupal\Unit\source;
+
+use Drupal\Core\Database\Connection;
+use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
+
+/**
+ * Extends the DrupalSqlBase abstract class.
+ */
+class TestDrupalSqlBase extends DrupalSqlBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fields() {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function query() {
+ }
+
+ /**
+ * Tweaks DrupalSqlBase to set a new database connection for tests.
+ *
+ * @param \Drupal\Core\Database\Connection
+ * The new connection to use.
+ *
+ * @see \Drupal\Tests\migrate\Unit\MigrateSourceSqlTestCase
+ */
+ public function setDatabase(Connection $database) {
+ $this->database = $database;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIds() {
+ return [];
+ }
+
+}