3 namespace Drupal\Tests\migrate\Unit;
5 use Drupal\Core\Database\Connection;
6 use Drupal\migrate\Plugin\MigrationInterface;
7 use Drupal\migrate\MigrateException;
8 use Drupal\migrate\Plugin\migrate\id_map\Sql;
9 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
12 * Defines a SQL ID map for use in tests.
14 class TestSqlIdMap extends Sql implements \Iterator {
17 * Constructs a TestSqlIdMap object.
19 * @param \Drupal\Core\Database\Connection $database
21 * @param array $configuration
23 * @param string $plugin_id
24 * The plugin ID for the migration process to do.
25 * @param mixed $plugin_definition
26 * The configuration for the plugin.
27 * @param \Drupal\migrate\Plugin\MigrationInterface $migration
28 * The migration to do.
29 * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
30 * The event dispatcher service.
32 public function __construct(Connection $database, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
33 $this->database = $database;
34 parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher);
40 public function getDatabase() {
41 return parent::getDatabase();
45 * Gets the field schema.
47 * @param array $id_definition
48 * An array defining the field, with a key 'type'.
51 * A field schema depending on value of key 'type'. An empty array is
52 * returned if 'type' is not defined.
54 * @throws \Drupal\migrate\MigrateException
56 protected function getFieldSchema(array $id_definition) {
57 if (!isset($id_definition['type'])) {
60 switch ($id_definition['type']) {
75 throw new MigrateException($id_definition['type'] . ' not supported');