public function ProductTest::testProduct in Commerce Migrate 3.0.x
Same name in this branch
- 3.0.x modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductTest::testProduct()
- 3.0.x modules/magento/tests/src/Kernel/Migrate/magento2/ProductTest.php \Drupal\Tests\commerce_migrate_magento\Kernel\Migrate\magento2\ProductTest::testProduct()
- 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\ProductTest::testProduct()
- 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductTest::testProduct()
- 3.0.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/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductTest::testProduct()
- 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\ProductTest::testProduct()
Test product migration.
1 method overrides ProductTest::testProduct()
- ProductRollbackTest::testProduct in modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc6/ ProductRollbackTest.php - Test product migration rollback.
File
- modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc6/ ProductTest.php, line 49
Class
- ProductTest
- Tests Product migration.
Namespace
Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6Code
public function testProduct() {
$this
->assertProductEntity(1, 'product', '1', 'Bath Towel', TRUE, [
'1',
], [
'1',
]);
$variation = [
'id' => 1,
'type' => 'product',
'uid' => '1',
'sku' => 'towel-bath-001',
'price' => '20.000000',
'currency' => 'NZD',
'product_id' => '1',
'title' => 'Bath Towel',
'order_item_type_id' => 'default',
'created_time' => '1492867780',
'changed_time' => NULL,
'attributes' => NULL,
];
$this
->assertProductVariationEntity($variation);
$this
->assertProductEntity(2, 'product', '1', 'Beach Towel', TRUE, [
'1',
], [
'2',
]);
$variation = [
'id' => 2,
'type' => 'product',
'uid' => '1',
'sku' => 'towel-beach-001',
'price' => '15.000000',
'currency' => 'NZD',
'product_id' => '2',
'title' => 'Beach Towel',
'order_item_type_id' => 'default',
'created_time' => '1492989418',
'changed_time' => NULL,
'attributes' => NULL,
];
$this
->assertProductVariationEntity($variation);
$this
->assertProductEntity(3, 'product', '1', 'Fairy cake', TRUE, [
'1',
], [
'3',
]);
$variation = [
'id' => 3,
'type' => 'product',
'uid' => '1',
'sku' => 'Fairy-Cake-001',
'price' => '1500.000000',
'currency' => 'NZD',
'product_id' => '3',
'title' => 'Fairy cake',
'order_item_type_id' => 'default',
'created_time' => '1492989703',
'changed_time' => NULL,
'attributes' => NULL,
];
$this
->assertProductVariationEntity($variation);
$product = Product::load(3);
$this
->assertEquals("Necessary ingredient for the Total Perspective Vortex.", $product->body->value);
$this
->assertEquals("5", $product->field_integer->value);
$this
->assertEquals("Low", $product->field_sustain->value);
// There is only one node in the fixture that is not a product, node 6.
$node = Node::load(6);
$this
->assertInstanceOf(Node::class, $node, "Node 6 exists.");
// Nodes 1 to 5 and node 7 and 8 should not exist.
$nodes = [
1,
2,
3,
4,
5,
7,
8,
];
foreach ($nodes as $node) {
$node = Node::load($node);
$this
->assertNull($node, "Node {$node} exists.");
}
// Test that translations are working.
$product = Product::load(1);
$this
->assertSame('en', $product->langcode->value);
$this
->assertTrue($product
->hasTranslation('es'), "Product 1 missing the Spanish translation");
$product = Product::load(2);
$this
->assertSame('und', $product->langcode->value);
$this
->assertFalse($product
->hasTranslation('es'), "Product 2 should not have a Spanish translation");
$product = Product::load(3);
$this
->assertSame('en', $product->langcode->value);
$this
->assertTrue($product
->hasTranslation('es'), "Product 3 missing the Spanish translation");
// Test that content_translation_source is set.
$manager = $this->container
->get('content_translation.manager');
$this
->assertSame('en', $manager
->getTranslationMetadata($product
->getTranslation('es'))
->getSource());
}