function GetTest::testTransformSourceArray

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/process/GetTest.php \Drupal\Tests\migrate\Unit\process\GetTest::testTransformSourceArray()
  2. 8.9.x core/modules/migrate/tests/src/Unit/process/GetTest.php \Drupal\Tests\migrate\Unit\process\GetTest::testTransformSourceArray()
  3. 11.x 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 32

Class

GetTest
Tests the get process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformSourceArray() : void {
    $map = [
        'test1' => 'source_value1',
        'test2' => 'source_value2',
    ];
    $this->plugin = new Get([
        'source' => [
            'test1',
            'test2',
        ],
    ], '', []);
    $this->row
        ->expects($this->exactly(2))
        ->method('get')
        ->willReturnCallback(function ($argument) use ($map) {
        return $map[$argument];
    });
    $value = $this->plugin
        ->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame([
        'source_value1',
        'source_value2',
    ], $value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.