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
parent
0a6e463907
commit
5123f7568d
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue