protected function DrushTestBase::setUp in Media Migration 8
Overrides BrowserTestBase::setUp
2 calls to DrushTestBase::setUp()
- DrushWithCoreMigrationsFromFileTest::setUp in tests/
src/ Functional/ DrushWithCoreMigrationsFromFileTest.php - DrushWithCoreMigrationsFromMediaTest::setUp in tests/
src/ Functional/ DrushWithCoreMigrationsFromMediaTest.php
2 methods override DrushTestBase::setUp()
- DrushWithCoreMigrationsFromFileTest::setUp in tests/
src/ Functional/ DrushWithCoreMigrationsFromFileTest.php - DrushWithCoreMigrationsFromMediaTest::setUp in tests/
src/ Functional/ DrushWithCoreMigrationsFromMediaTest.php
File
- tests/
src/ Functional/ DrushTestBase.php, line 53
Class
- DrushTestBase
- Base class for testing media migrations executed with Drush.
Namespace
Drupal\Tests\media_migration\FunctionalCode
protected function setUp() {
parent::setUp();
$shortcut_links = \Drupal::entityTypeManager()
->getStorage('shortcut')
->loadMultiple();
foreach ($shortcut_links as $shortcut) {
$shortcut
->delete();
}
$shortcut_sets = \Drupal::entityTypeManager()
->getStorage('shortcut_set')
->loadMultiple();
foreach ($shortcut_sets as $shortcut_set) {
$shortcut_set
->delete();
}
$module_installer = \Drupal::service('module_installer');
assert($module_installer instanceof ModuleInstallerInterface);
$module_installer
->uninstall([
'shortcut',
]);
// The 'default' and 'migrate' DB key strings are 7 chars long. Using a
// different length ensures that the migration connection key used for
// testing cannot be 'default' or 'migrate'.
$source_db_key = $this
->randomMachineName(8);
$this
->createMigrationConnection($source_db_key);
$this->sourceDatabase = Database::getConnection('default', $source_db_key);
$this
->loadFixture($this
->getFixtureFilePath());
// Delete preexisting media types.
$media_types = $this->container
->get('entity_type.manager')
->getStorage('media_type')
->loadMultiple();
foreach ($media_types as $media_type) {
$media_type
->delete();
}
// Delete preexisting node types.
$node_types = $this->container
->get('entity_type.manager')
->getStorage('node_type')
->loadMultiple();
foreach ($node_types as $node_type) {
$node_type
->delete();
}
$this
->resetAll();
}