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

8.7.x
Alex Pott 2018-11-19 12:04:58 +00:00
parent 0a6e463907
commit 5123f7568d
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 17 additions and 1 deletions

View File

@ -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();
}
/**

View File

@ -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;