Commit 80194631 authored by alexpott's avatar alexpott

Issue #3081123 by quietone, alexpott: Add checkrequirements to VariableTranslation source plugin

(cherry picked from commit de2072c9)
parent 4bd31c2a
......@@ -4,6 +4,7 @@
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
......@@ -12,7 +13,7 @@
*
* @MigrateSource(
* id = "d6_variable_translation",
* source_module = "system",
* source_module = "i18n",
* )
*/
class VariableTranslation extends DrupalSqlBase {
......@@ -98,4 +99,14 @@ public function getIds() {
return $ids;
}
/**
* {@inheritdoc}
*/
public function checkRequirements() {
if (!$this->getDatabase()->schema()->tableExists('i18n_variable')) {
throw new RequirementsException("Source database table 'i18n_variable' does not exist");
}
parent::checkRequirements();
}
}
<?php
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
use Drupal\migrate\Exception\RequirementsException;
/**
* Tests check requirements for variable translation source plugin.
*
* @group migrate_drupal
*/
class VariableTranslationCheckRequirementsTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['config_translation'];
/**
* {@inheritdoc}
*/
public function setup() {
parent::setUp();
$this->sourceDatabase->schema()->dropTable('i18n_variable');
}
/**
* Tests exception in thrown when the i18n_variable table does not exist.
*/
public function testCheckRequirements() {
$this->expectException(RequirementsException::class);
$this->expectExceptionMessage("Source database table 'i18n_variable' does not exist");
$this->getMigration('d6_system_maintenance_translation')
->getSourcePlugin()
->checkRequirements();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment