public function ProductTest::testProduct in Commerce Migrate 3.1.x
Same name in this branch
- 3.1.x modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductTest::testProduct()
- 3.1.x modules/magento/tests/src/Kernel/Migrate/magento2/ProductTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProductTest::testProduct()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProductTest::testProduct()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductTest::testProduct()
- 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductTest::testProduct()
Same name and namespace in other branches
- 8.2 modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductTest::testProduct()
- 3.0.x modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductTest::testProduct()
Test product migration from CSV source file.
File
- modules/
csv_example/ tests/ src/ Kernel/ Migrate/ ProductTest.php, line 144
Class
- ProductTest
- Tests Product migration.
Namespace
Drupal\Tests\commerce_migrate_csv_example\Kernel\MigrateCode
public function testProduct() {
$this
->executeMigrations([
'csv_example_taxonomy_term',
'csv_example_image',
'csv_example_attribute_value',
'csv_example_product_variation',
'csv_example_paragraph_cta',
'csv_example_paragraph_with_paragraph_reference',
'csv_example_product',
]);
$variations = [
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10',
'11',
'12',
'13',
'14',
'15',
];
// Initialize the term array for testing.
$terms = [
'field_category' => [
[
'target_id' => '1',
],
],
'field_season' => [
[
'target_id' => '2',
],
],
];
// Initialize the suggested products array for testing.
$suggested = [];
$this
->assertProductEntity(1, 'default', '0', 'TherMaxx', TRUE, [
'1',
], $variations);
$this
->assertProductEntityAdditions(1, $terms, $suggested);
$terms['field_season'] = [
[
'target_id' => '3',
],
];
$this
->assertProductEntity(2, 'default', '0', 'Aquaseal', TRUE, [
'1',
], [
'16',
'18',
]);
$this
->assertProductEntityAdditions(2, $terms, $suggested);
$terms['field_category'] = [
[
'target_id' => '4',
],
];
$terms['field_season'] = [
[
'target_id' => '2',
],
];
$this
->assertProductEntity(3, 'default', '0', 'Zip Care', TRUE, [
'1',
], [
'17',
]);
$this
->assertProductEntityAdditions(3, $terms, $suggested);
$suggested = [
[
'target_id' => '1',
],
[
'target_id' => '3',
],
[
'target_id' => '2',
],
];
$this
->assertProductEntity(4, 'default', '0', 'Wetsuit Shampoo', TRUE, [
'1',
], [
'19',
]);
$this
->assertProductEntityAdditions(4, $terms, $suggested);
$suggested = [];
$this
->assertProductEntity(5, 'default', '0', 'BC Life', TRUE, [
'1',
], [
'20',
]);
$this
->assertProductEntityAdditions(5, $terms, $suggested);
$this
->assertProductEntity(6, 'default', '0', 'MiraZyme', TRUE, [
'1',
], [
'21',
'23',
]);
$this
->assertProductEntityAdditions(6, $terms, $suggested);
$this
->assertProductEntity(7, 'default', '0', 'Sea Quick', TRUE, [
'1',
], [
'26',
]);
$this
->assertProductEntityAdditions(7, $terms, $suggested);
$terms['field_category'] = [
[
'target_id' => '5',
],
];
$terms['field_season'] = [
[
'target_id' => '6',
],
];
$this
->assertProductEntity(8, 'default', '0', 'GoPro 4', TRUE, [
'1',
], [
'27',
]);
$this
->assertProductEntityAdditions(8, $terms, $suggested);
$suggested = [
[
'target_id' => '7',
],
[
'target_id' => '8',
],
];
$terms['field_category'] = [
[
'target_id' => '4',
],
];
$terms['field_season'] = [
[
'target_id' => '2',
],
];
$this
->assertProductEntity(9, 'default', '0', 'Sea Gold Anti-Fog', TRUE, [
'1',
], [
'22',
]);
$this
->assertProductEntityAdditions(9, $terms, $suggested);
$suggested = [];
$this
->assertProductEntity(10, 'default', '0', 'Sea Buff', TRUE, [
'1',
], [
'24',
]);
$this
->assertProductEntityAdditions(10, $terms, $suggested);
$this
->assertProductEntity(11, 'default', '0', 'Sea Gold / Sea Buff Combo', TRUE, [
'1',
], [
'25',
]);
$this
->assertProductEntityAdditions(11, $terms, $suggested);
$terms['field_category'] = [
[
'target_id' => '5',
],
];
$terms['field_season'] = [
[
'target_id' => '6',
],
];
$suggested = [
[
'target_id' => '8',
],
];
$this
->assertProductEntity(12, 'default', '0', 'Hero 5', TRUE, [
'1',
], [
'28',
]);
$this
->assertProductEntityAdditions(12, $terms, $suggested);
}