Skip to content
Snippets Groups Projects
Unverified Commit de2072c9 authored by Alex Pott's avatar Alex Pott
Browse files

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

parent 81c058aa
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment