protected function AttributeTermTest::setUp in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 modules/commerce/tests/src/Kernel/Migrate/commerce1/AttributeTermTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\AttributeTermTest::setUp()
- 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/AttributeTermTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\AttributeTermTest::setUp()
Overrides MigrateDrupal7TestBase::setUp
File
- modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ AttributeTermTest.php, line 44
Class
- AttributeTermTest
- Tests attribute value migration.
Namespace
Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1Code
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('commerce_product');
$this
->installEntitySchema('commerce_product_variation');
$this
->installEntitySchema('profile');
// Setup files needed for the taxonomy_term:collection migration.
$this
->installSchema('file', [
'file_usage',
]);
$this
->installEntitySchema('file');
$this->container
->get('stream_wrapper_manager')
->registerWrapper('public', PublicStream::class, StreamWrapperInterface::NORMAL);
$fs = \Drupal::service('file_system');
// The public file directory active during the test will serve as the
// root of the fictional Drupal 7 site we're migrating.
$fs
->mkdir('public://sites/default/files', NULL, TRUE);
$file_paths = [
'collection-banner-to_wear.jpg',
'collection-banner-to_carry.jpg',
'collection-banner-to_drink_with.jpg',
'collection-banner-to_geek_out.jpg',
];
foreach ($file_paths as $file_path) {
$filename = 'public://sites/default/files/' . $file_path;
file_put_contents($filename, str_repeat('*', 8));
}
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = $this
->getMigration('d7_file');
// Set the source plugin's source_base_path configuration value, which
// would normally be set by the user running the migration.
$source = $migration
->getSourceConfiguration();
$source['constants']['source_base_path'] = $fs
->realpath('public://');
$migration
->set('source', $source);
$this
->executeMigration($migration);
$this
->installEntitySchema('taxonomy_term');
$this
->installEntitySchema('commerce_product_attribute_value');
$this
->migrateFields();
$this
->executeMigrations([
'd7_taxonomy_term',
]);
}