public function ProductVariationTest::assertProductVariationEntityAdditions in Commerce Migrate 3.0.x
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::assertProductVariationEntityAdditions()
- 3.1.x modules/csv_example/tests/src/Kernel/Migrate/ProductVariationTest.php \Drupal\Tests\commerce_migrate_csv_example\Kernel\Migrate\ProductVariationTest::assertProductVariationEntityAdditions()
Asserts additions to a product variation.
Parameters
int $id: The product variation id.
array $attributes: Array of attribute names and id.
array $files: Array of file information.
1 call to ProductVariationTest::assertProductVariationEntityAdditions()
- ProductVariationTest::testProductVariation in modules/
csv_example/ tests/ src/ Kernel/ Migrate/ ProductVariationTest.php - Test product variation migration from CSV source file.
File
- modules/
csv_example/ tests/ src/ Kernel/ Migrate/ ProductVariationTest.php, line 837
Class
- ProductVariationTest
- Tests Product migration.
Namespace
Drupal\Tests\commerce_migrate_csv_example\Kernel\MigrateCode
public function assertProductVariationEntityAdditions($id, array $attributes, array $files) {
$variation = ProductVariation::load($id);
foreach ($attributes as $name => $data) {
if ($data) {
$this
->assertSame($data['id'], $variation
->getAttributeValueId($name));
$this
->assertSame($data['value'], $variation
->getAttributeValue($name)
->getName());
}
}
foreach ($files as $name => $data) {
if ($data) {
$this
->assertSame([
$data,
], $variation
->get($name)
->getValue(), "File data for {$name} is incorrect.");
}
else {
$this
->assertSame($data, $variation
->get($name)
->getValue());
}
}
}