ProductVariationFileTest.php in Commerce Migrate 3.1.x
File
modules/csv_example/tests/src/Unit/Plugin/migrate/process/ProductVariationFileTest.php
View source
<?php
namespace Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
use Drupal\commerce_migrate_csv_example\Plugin\migrate\process\ProductVariationFile;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
class ProductVariationFileTest extends MigrateProcessTestCase {
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);
}
}