public function ProductTest::testProduct in Commerce Migrate 8.2
Same name in this branch
- 8.2 modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductTest::testProduct()
- 8.2 modules/magento/tests/src/Kernel/Migrate/magento2/ProductTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProductTest::testProduct()
- 8.2 modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProductTest::testProduct()
- 8.2 modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductTest::testProduct()
- 8.2 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
- 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductTest::testProduct()
- 3.0.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductTest::testProduct()
Test product migration from Drupal 7 to 8.
1 method overrides ProductTest::testProduct()
- ProductRollbackTest::testProduct in modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ ProductRollbackTest.php - Test product migration rollback.
File
- modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ ProductTest.php, line 141
Class
- ProductTest
- Tests product migration.
Namespace
Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1Code
public function testProduct() {
$this
->assertProductEntity(15, 'bags_cases', '1', 'Go green with Drupal Commerce Reusable Tote Bag', TRUE, [
'1',
], [
'1',
]);
$this
->assertProductEntity(22, 'hats', '1', 'Commerce Guys Baseball Cap', TRUE, [
'1',
], [
'1',
]);
$this
->assertProductEntity(23, 'hats', '1', 'Drupal Commerce Ski Cap', TRUE, [
'1',
], [
'1',
]);
// Tests a product with multiple variations.
$this
->assertProductEntity(26, 'storage_devices', '1', 'Commerce Guys USB Key', TRUE, [
'1',
], [
'28',
'29',
'30',
]);
// Test values of a product variation field.
$variation = ProductVariation::load(1);
$this
->assertInstanceOf(ProductVariation::class, $variation);
$expected = [
[
'target_id' => '1',
'alt' => NULL,
'title' => NULL,
'width' => '860',
'height' => '842',
],
[
'target_id' => '2',
'alt' => NULL,
'title' => NULL,
'width' => '860',
'height' => '1251',
],
[
'target_id' => '3',
'alt' => NULL,
'title' => NULL,
'width' => '860',
'height' => '1100',
],
];
$actual = $variation
->get('field_images')
->getValue();
$this
->assertCount(3, $actual);
$target_id = array_column($actual, 'target_id');
array_multisort($target_id, SORT_ASC, SORT_NUMERIC, $actual);
$this
->assertSame($expected, $actual);
// Test values of a product field.
$product = Product::load(15);
$this
->assertInstanceOf(Product::class, $product);
$this
->assertCount(1, $product
->get('field_category')
->getValue());
$this
->assertSame('50', $product
->get('field_category')
->getValue()[0]['target_id']);
}