Commit 199b4141 authored by Jess's avatar Jess
Browse files

Issue #2790111 by neclimdul, mikeryan: DrupalSqlBase doesn't include missing...

Issue #2790111 by neclimdul, mikeryan: DrupalSqlBase doesn't include missing source in requirements exception

(cherry picked from commit 6f7f400b)
parent 30ce23e0
Loading
Loading
Loading
Loading
+1 −1
Changes for core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public function checkRequirements() {
          }
        }
        else {
          throw new RequirementsException('The module ' . $this->pluginDefinition['source_provider'] . ' is not enabled in the source site.');
          throw new RequirementsException('The module ' . $this->pluginDefinition['source_provider'] . ' is not enabled in the source site.', ['source_provider' => $this->pluginDefinition['source_provider']]);
        }
      }
    }
+9 −1
Changes for core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ class DrupalSqlBaseTest extends MigrateTestCase {
   * @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 */
@@ -52,8 +51,17 @@ public function testSourceProviderNotActive() {
    $plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this->getMigration(), $state, $entity_manager);
    $plugin->setDatabase($this->getDatabase($this->databaseContents));
    $system_data = $plugin->getSystemData();
    $this->setExpectedException(RequirementsException::class, 'The module module1 is not enabled in the source site.');
    try {
      $plugin->checkRequirements();
    }
    catch (RequirementsException $e) {
      // Ensure requirements are set on the exception.
      $this->assertEquals(['source_provider' => 'module1'], $e->getRequirements());
      // Re-throw so PHPUnit can assert the exception.
      throw $e;
    }
  }

}