You are here

public function MigrateExecutableTest::testProcessRowEmptyDestination in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testProcessRowEmptyDestination()
  2. 9 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::testProcessRowEmptyDestination()

Tests the processRow method.

File

core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php, line 349

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testProcessRowEmptyDestination() {
  $expected = [
    'test' => 'test destination',
    'test1' => 'test1 destination',
    'test2' => NULL,
  ];
  $row = new Row();
  $plugins = [];
  foreach ($expected as $key => $value) {
    $plugin = $this
      ->prophesize(MigrateProcessInterface::class);
    $plugin
      ->getPluginDefinition()
      ->willReturn([]);
    $plugin
      ->transform(NULL, $this->executable, $row, $key)
      ->willReturn($value);
    $plugin
      ->multiple()
      ->willReturn(TRUE);
    $plugins[$key][0] = $plugin
      ->reveal();
  }
  $this->migration
    ->method('getProcessPlugins')
    ->willReturn($plugins);
  $this->executable
    ->processRow($row);
  foreach ($expected as $key => $value) {
    $this
      ->assertSame($value, $row
      ->getDestinationProperty($key));
  }
  $this
    ->assertCount(2, $row
    ->getDestination());
  $this
    ->assertSame([
    'test2',
  ], $row
    ->getEmptyDestinationProperties());
}