MigrateDrupalTestBase.php

Same filename and directory in other branches
  1. 9 core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  2. 9 core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php
  3. 10 core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  4. 10 core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php
  5. 11.x core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php
  6. 11.x core/modules/tracker/tests/src/Kernel/Migrate/d7/MigrateDrupalTestBase.php

Namespace

Drupal\Tests\migrate_drupal\Kernel

File

core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php

View source
<?php

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 {
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    public static $modules = [
        'system',
        'user',
        'field',
        'migrate_drupal',
        'options',
        'file',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        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 (substr($path, -3) == '.gz') {
            $path = 'compress.zlib://' . $path;
        }
        require $path;
        Database::setActiveConnection($default_db);
    }

}

Classes

Title Deprecated Summary
MigrateDrupalTestBase Base class for Drupal migration tests.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.