summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-11-19 12:04:58 (GMT)
committerAlex Pott2018-11-19 12:05:04 (GMT)
commitb6f899260067a40612027ba115ff300ab09d5584 (patch)
tree44c336665a6bb20275d600f0c941d2a30ac3c6aa
parent472574a3bdcedd9dd7268761da30050e0d5068cb (diff)
Issue #3008720 by quietone, neclimdul, dhirendra.mishra, heddn: DrupalSqlBase::getSystemData eats exceptions causing DrupalSqlBase::checkRequirements to be less useful on database errors than it should be
(cherry picked from commit 5123f7568d55359f6670f072cad4c01a979c7886)
-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.php16
2 files changed, 17 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 c8b44f8..15acb02 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php
@@ -102,6 +102,7 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
* {@inheritdoc}
*/
public function checkRequirements() {
+ parent::checkRequirements();
if ($this->pluginDefinition['requirements_met'] === TRUE) {
if (isset($this->pluginDefinition['source_module'])) {
if ($this->moduleExists($this->pluginDefinition['source_module'])) {
@@ -114,7 +115,6 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
}
}
}
- parent::checkRequirements();
}
/**
diff --git a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
index ebd9334..fdaf4b1 100644
--- a/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
+++ b/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php
@@ -63,6 +63,22 @@ class DrupalSqlBaseTest extends MigrateTestCase {
}
}
+ /**
+ * @covers ::checkRequirements
+ */
+ public function testSourceDatabaseError() {
+ $plugin_definition['requirements_met'] = TRUE;
+ $plugin_definition['source_module'] = '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([], 'test', $plugin_definition, $this->getMigration(), $state, $entity_manager);
+ $system_data = $plugin->getSystemData();
+ $this->setExpectedException(RequirementsException::class, 'No database connection configured for source plugin test');
+ $plugin->checkRequirements();
+ }
+
}
namespace Drupal\Tests\migrate_drupal\Unit\source;