Pull merge.
[yaffs-website] / web / core / modules / migrate_drupal / tests / src / Unit / source / DrupalSqlBaseTest.php
index 6dd5925748871e8447f5b05589a8f833e6fbcf8b..fdaf4b10af7ca99ea67c8be49abcb425e5725108 100644 (file)
@@ -43,7 +43,7 @@ class DrupalSqlBaseTest extends MigrateTestCase {
    */
   public function testSourceProviderNotActive() {
     $plugin_definition['requirements_met'] = TRUE;
-    $plugin_definition['source_provider'] = 'module1';
+    $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 */
@@ -57,12 +57,28 @@ class DrupalSqlBaseTest extends MigrateTestCase {
     }
     catch (RequirementsException $e) {
       // Ensure requirements are set on the exception.
-      $this->assertEquals(['source_provider' => 'module1'], $e->getRequirements());
+      $this->assertEquals(['source_module' => 'module1'], $e->getRequirements());
       // Re-throw so PHPUnit can assert the exception.
       throw $e;
     }
   }
 
+  /**
+   * @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;