You are here

public function GetTest::testTransformSourceArray in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/process/GetTest.php \Drupal\Tests\migrate\Unit\process\GetTest::testTransformSourceArray()

Tests the Get plugin when source is an array.

File

core/modules/migrate/tests/src/Unit/process/GetTest.php, line 42
Contains \Drupal\Tests\migrate\Unit\process\GetTest.

Class

GetTest
Tests the get process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformSourceArray() {
  $map = array(
    'test1' => 'source_value1',
    'test2' => 'source_value2',
  );
  $this->plugin
    ->setSource(array(
    'test1',
    'test2',
  ));
  $this->row
    ->expects($this
    ->exactly(2))
    ->method('getSourceProperty')
    ->will($this
    ->returnCallback(function ($argument) use ($map) {
    return $map[$argument];
  }));
  $value = $this->plugin
    ->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
  $this
    ->assertSame($value, array(
    'source_value1',
    'source_value2',
  ));
}