You are here

public function ProductVariationFileTest::testSuggestedProducts in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/csv_example/tests/src/Unit/Plugin/migrate/process/ProductVariationFileTest.php \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\ProductVariationFileTest::testSuggestedProducts()
  2. 3.1.x modules/csv_example/tests/src/Unit/Plugin/migrate/process/ProductVariationFileTest.php \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\ProductVariationFileTest::testSuggestedProducts()

Tests Product variation file process plugin.

File

modules/csv_example/tests/src/Unit/Plugin/migrate/process/ProductVariationFileTest.php, line 24

Class

ProductVariationFileTest
Tests the Product variation file process plugin.

Namespace

Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process

Code

public function testSuggestedProducts() {
  $executable = $this
    ->prophesize(MigrateExecutableInterface::class)
    ->reveal();
  $row = $this
    ->prophesize(Row::class)
    ->reveal();
  $migration = $this
    ->prophesize(MigrationInterface::class)
    ->reveal();
  $value = [
    'fid' => 1,
    'list' => TRUE,
    'data' => serialize([]),
  ];
  $migrate_process = $this
    ->prophesize(MigrateProcessInterface::class);
  $migrate_process
    ->transform($value, $executable, $row, 'foo')
    ->willReturn(1);
  $plugin = new ProductVariationFile([], 'csv_example_image', [], $migration, $migrate_process
    ->reveal());
  $transformed = $plugin
    ->transform($value, $executable, $row, 'foo');
  $expected = [
    'target_id' => 1,
    'description' => '',
    'alt' => '',
    'title' => '',
  ];
  $this
    ->assertSame($expected, $transformed);
}