063c99cb36473f234336648ed0f4515a5d20f400
[yaffs-website] / web / core / modules / migrate_drupal / tests / src / Kernel / MigrateDrupalTestBase.php
1 <?php
2
3 namespace Drupal\Tests\migrate_drupal\Kernel;
4
5 use Drupal\Core\Database\Database;
6 use Drupal\Tests\migrate\Kernel\MigrateTestBase;
7
8 /**
9  * Base class for Drupal migration tests.
10  */
11 abstract class MigrateDrupalTestBase extends MigrateTestBase {
12
13   /**
14    * Modules to enable.
15    *
16    * @var array
17    */
18   public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->installEntitySchema('user');
26     $this->installConfig(['migrate_drupal', 'system']);
27   }
28
29   /**
30    * Loads a database fixture into the source database connection.
31    *
32    * @param string $path
33    *   Path to the dump file.
34    */
35   protected function loadFixture($path) {
36     $default_db = Database::getConnection()->getKey();
37     Database::setActiveConnection($this->sourceDatabase->getKey());
38
39     if (substr($path, -3) == '.gz') {
40       $path = 'compress.zlib://' . $path;
41     }
42     require $path;
43
44     Database::setActiveConnection($default_db);
45   }
46
47 }