
| Current Path : /var/www/html/strat/web/core/modules/migrate_drupal/tests/src/Kernel/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/strat/web/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php |
<?php
declare(strict_types=1);
namespace Drupal\Tests\migrate_drupal\Kernel;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate\Kernel\MigrateTestBase;
/**
* Base class for Drupal migration tests.
*/
abstract class MigrateDrupalTestBase extends MigrateTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
'field',
'migrate_drupal',
'options',
'file',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$module_handler = \Drupal::moduleHandler();
if ($module_handler->moduleExists('node')) {
$this->installEntitySchema('node');
}
if ($module_handler->moduleExists('comment')) {
$this->installEntitySchema('comment');
}
if ($module_handler->moduleExists('taxonomy')) {
$this->installEntitySchema('taxonomy_term');
}
if ($module_handler->moduleExists('user')) {
$this->installEntitySchema('user');
}
$this->installConfig(['migrate_drupal', 'system']);
}
/**
* Loads a database fixture into the source database connection.
*
* @param string $path
* Path to the dump file.
*/
protected function loadFixture($path) {
$default_db = Database::getConnection()->getKey();
Database::setActiveConnection($this->sourceDatabase->getKey());
if (str_ends_with($path, '.gz')) {
$path = 'compress.zlib://' . $path;
}
require $path;
Database::setActiveConnection($default_db);
}
}