protected function ProductVariationTest::setUp in Commerce Migrate 3.1.x
Same name in this branch
- 3.1.x modules/csv_example/tests/src/Kernel/Migrate/ProductVariationTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductVariationTest::setUp()
- 3.1.x modules/shopify/tests/src/Kernel/Migrate/ProductVariationTest.php \Drupal\Tests\commerce_migrate_shopify\Kernel\Migrate\shopify\ProductVariationTest::setUp()
- 3.1.x modules/magento/tests/src/Kernel/Migrate/magento2/ProductVariationTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProductVariationTest::setUp()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductVariationTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProductVariationTest::setUp()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductVariationTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductVariationTest::setUp()
- 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductVariationTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductVariationTest::setUp()
Same name and namespace in other branches
- 8.2 modules/csv_example/tests/src/Kernel/Migrate/ProductVariationTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductVariationTest::setUp()
- 3.0.x modules/csv_example/tests/src/Kernel/Migrate/ProductVariationTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductVariationTest::setUp()
Overrides CsvTestBase::setUp
File
- modules/
csv_example/ tests/ src/ Kernel/ Migrate/ ProductVariationTest.php, line 58
Class
- ProductVariationTest
- Tests Product migration.
Namespace
Drupal\Tests\commerce_migrate_csv_example\Kernel\MigrateCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('taxonomy_term');
$this
->installEntitySchema('commerce_product_variation');
$this
->installEntitySchema('commerce_product');
$this
->installEntitySchema('commerce_product_attribute');
$this
->installEntitySchema('commerce_product_attribute_value');
$this
->installConfig('commerce_product');
$this->fs = \Drupal::service('file_system');
$this
->installEntitySchema('user');
// Copy the source files.
$this
->fileMigrationSetup(__DIR__ . '/../../../fixtures/images');
$this
->createAttribute([
'Accessory Size',
'Color',
'Shoe Size',
'Size',
]);
$images = [
'product_image',
'product_image_2',
'product_image_3',
];
foreach ($images as $image) {
$field_name = 'field_' . $image;
$field_storage_definition = [
'field_name' => $field_name,
'entity_type' => 'commerce_product_variation',
'type' => 'image',
'cardinality' => 1,
];
$storage = FieldStorageConfig::create($field_storage_definition);
$storage
->save();
$field_instance = [
'field_name' => $field_name,
'entity_type' => 'commerce_product_variation',
'bundle' => 'default',
'label' => $image,
'settings' => [
'handler' => 'default:file',
],
];
$field = FieldConfig::create($field_instance);
$field
->save();
}
}