Get example


  public function testSubProcess($process_configuration$source_values = []) {
    $migration = $this->getMigration();
    // Set up the properties for the sub_process.     $plugin = new SubProcess($process_configuration, 'sub_process', []);
    // Manually create the plugins. Migration::getProcessPlugins does this     // normally but the plugin system is not available.     foreach ($process_configuration['process'] as $destination => $source) {
      $sub_process_plugins[$destination][] = new Get(['source' => $source], 'get', []);
    }
    // Set up the key plugins.     $key_plugin['key'][] = new Get(['source' => '@id'], 'get', []);
    $migration->expects($this->exactly(2))
      ->method('getProcessPlugins')
      ->willReturnOnConsecutiveCalls(
        $sub_process_plugins,
        $key_plugin,
      );
    $event_dispatcher = $this->createMock(EventDispatcherInterface::class);
    $migrate_executable = new MigrateExecutable($migration$this->createMock(MigrateMessageInterface::class)$event_dispatcher);

    

class GetTest extends MigrateProcessTestCase {

  /** * Tests the Get plugin when source is a string. */
  public function testTransformSourceString() {
    $this->row->expects($this->once())
      ->method('get')
      ->with('test')
      ->willReturn('source_value');
    $this->plugin = new Get(['source' => 'test'], '', []);
    $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame('source_value', $value);
  }

  /** * Tests the Get plugin when source is an array. */
  public function testTransformSourceArray() {
    $map = [
      'test1' => 'source_value1',
      'test2' => 'source_value2',
    ];
Home | Imprint | This part of the site doesn't use cookies.