Mercurial > hg > isophonics-drupal-site
comparison core/modules/migrate/tests/src/Unit/TestSqlIdMap.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\migrate\Unit; | |
4 | |
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; | |
10 | |
11 /** | |
12 * Defines a SQL ID map for use in tests. | |
13 */ | |
14 class TestSqlIdMap extends Sql implements \Iterator { | |
15 | |
16 /** | |
17 * Constructs a TestSqlIdMap object. | |
18 * | |
19 * @param \Drupal\Core\Database\Connection $database | |
20 * The database. | |
21 * @param array $configuration | |
22 * The 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. | |
31 */ | |
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); | |
35 } | |
36 | |
37 /** | |
38 * {@inheritdoc} | |
39 */ | |
40 public function getDatabase() { | |
41 return parent::getDatabase(); | |
42 } | |
43 | |
44 /** | |
45 * Gets the field schema. | |
46 * | |
47 * @param array $id_definition | |
48 * An array defining the field, with a key 'type'. | |
49 * | |
50 * @return array | |
51 * A field schema depending on value of key 'type'. An empty array is | |
52 * returned if 'type' is not defined. | |
53 * | |
54 * @throws \Drupal\migrate\MigrateException | |
55 */ | |
56 protected function getFieldSchema(array $id_definition) { | |
57 if (!isset($id_definition['type'])) { | |
58 return []; | |
59 } | |
60 switch ($id_definition['type']) { | |
61 case 'integer': | |
62 return [ | |
63 'type' => 'int', | |
64 'not null' => TRUE, | |
65 ]; | |
66 | |
67 case 'string': | |
68 return [ | |
69 'type' => 'varchar', | |
70 'length' => 255, | |
71 'not null' => FALSE, | |
72 ]; | |
73 | |
74 default: | |
75 throw new MigrateException($id_definition['type'] . ' not supported'); | |
76 } | |
77 } | |
78 | |
79 } |