View source
<?php
namespace Drupal\Tests\comment\Kernel\Plugin\migrate\source;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class CommentTypeRequirementsTest extends MigrateDrupal7TestBase {
protected static $modules = [
'comment',
];
public function testCheckCommentTypeRequirements(array $disabled_source_modules, string $exception_message, string $migration_plugin_id) {
if (!empty($disabled_source_modules)) {
$this->sourceDatabase
->update('system')
->condition('name', $disabled_source_modules, 'IN')
->fields([
'status' => 0,
])
->execute();
}
$this
->expectException(RequirementsException::class);
$this
->expectExceptionMessage($exception_message);
$this
->getMigration($migration_plugin_id)
->getSourcePlugin()
->checkRequirements();
}
public function providerTestCheckCommentTypeRequirements() {
return [
'D6 comment is disabled on source' => [
'Disabled source modules' => [
'comment',
],
'RequirementsException message' => 'The module comment is not enabled in the source site.',
'migration' => 'd6_comment_type',
],
'D6 node is disabled on source' => [
'Disabled source modules' => [
'node',
],
'RequirementsException message' => 'The node module is not enabled in the source site.',
'migration' => 'd6_comment_type',
],
'D6 comment and node are disabled on source' => [
'Disabled source modules' => [
'comment',
'node',
],
'RequirementsException message' => 'The module comment is not enabled in the source site.',
'migration' => 'd6_comment_type',
],
'D7 comment is disabled on source' => [
'Disabled source modules' => [
'comment',
],
'RequirementsException message' => 'The module comment is not enabled in the source site.',
'migration' => 'd7_comment_type',
],
'D7 node is disabled on source' => [
'Disabled source modules' => [
'node',
],
'RequirementsException message' => 'The node module is not enabled in the source site.',
'migration' => 'd7_comment_type',
],
'D7 comment and node are disabled on source' => [
'Disabled source modules' => [
'comment',
'node',
],
'RequirementsException message' => 'The module comment is not enabled in the source site.',
'migration' => 'd7_comment_type',
],
];
}
}