コード例 #1
0
ファイル: MigrateSourceTest.php プロジェクト: scratch/gai
 /**
  * Get the source plugin to test.
  *
  * @param array $configuration
  *   The source configuration.
  * @param array $migrate_config
  *   The migration configuration to be used in parent::getMigration().
  * @param int $status
  *   The default status for the new rows to be imported.
  *
  * @return \Drupal\migrate\Plugin\MigrateSourceInterface
  *   A mocked source plugin.
  */
 protected function getSource($configuration = [], $migrate_config = [], $status = MigrateIdMapInterface::STATUS_NEEDS_UPDATE)
 {
     $this->migrationConfiguration = $this->defaultMigrationConfiguration + $migrate_config;
     $this->migration = parent::getMigration();
     $this->executable = $this->getMigrateExecutable($this->migration);
     // Update the idMap for Source so the default is that the row has already
     // been imported. This allows us to use the highwater mark to decide on the
     // outcome of whether we choose to import the row.
     $id_map_array = ['original_hash' => '', 'hash' => '', 'source_row_status' => $status];
     $this->idMap->expects($this->any())->method('getRowBySource')->willReturn($id_map_array);
     $constructor_args = [$configuration, 'd6_action', [], $this->migration];
     $methods = ['getModuleHandler', 'fields', 'getIds', '__toString', 'getIterator', 'prepareRow', 'initializeIterator', 'calculateDependencies'];
     $source_plugin = $this->getMock('\\Drupal\\migrate\\Plugin\\migrate\\source\\SourcePluginBase', $methods, $constructor_args);
     $source_plugin->expects($this->any())->method('fields')->willReturn([]);
     $source_plugin->expects($this->any())->method('getIds')->willReturn([]);
     $source_plugin->expects($this->any())->method('__toString')->willReturn('');
     $source_plugin->expects($this->any())->method('prepareRow')->willReturn(empty($migrate_config['prepare_row_false']));
     $source_plugin->expects($this->any())->method('initializeIterator')->willReturn([]);
     $iterator = new \ArrayIterator([$this->row]);
     $source_plugin->expects($this->any())->method('getIterator')->willReturn($iterator);
     $module_handler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $source_plugin->expects($this->any())->method('getModuleHandler')->willReturn($module_handler);
     $this->migration->expects($this->any())->method('getSourcePlugin')->willReturn($source_plugin);
     return $this->migration->getSourcePlugin();
 }
コード例 #2
0
 /**
  * Returns the source.
  *
  * Makes sure source is initialized based on migration settings.
  *
  * @return \Drupal\migrate\Plugin\MigrateSourceInterface
  *   The source.
  */
 protected function getSource()
 {
     if (!isset($this->source)) {
         $this->source = $this->migration->getSourcePlugin();
     }
     return $this->source;
 }
コード例 #3
0
ファイル: MigrateExecutable.php プロジェクト: scratch/gai
 /**
  * Returns the source.
  *
  * Makes sure source is initialized based on migration settings.
  *
  * @return \Drupal\migrate\Plugin\MigrateSourceInterface
  *   The source.
  */
 protected function getSource()
 {
     if (!isset($this->source)) {
         $this->source = $this->migration->getSourcePlugin();
         // @TODO, find out how to remove this.
         // @see https://www.drupal.org/node/2443617
         $this->source->migrateExecutable = $this;
     }
     return $this->source;
 }