function MigrateSqlIdMapEnsureTablesTest::testEnsureTablesNotExist
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesNotExist()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesNotExist()
- 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesNotExist()
Tests the ensureTables method when the tables do not exist.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapEnsureTablesTest.php, line 28
Class
- MigrateSqlIdMapEnsureTablesTest
- Tests the SQL ID map plugin ensureTables() method.
Namespace
Drupal\Tests\migrate\UnitCode
public function testEnsureTablesNotExist() : void {
$fields['source_ids_hash'] = [
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key',
];
$fields['sourceid1'] = [
'type' => 'int',
'not null' => TRUE,
];
$fields['sourceid2'] = [
'type' => 'int',
'not null' => TRUE,
];
$fields['destid1'] = [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
];
$fields['source_row_status'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::STATUS_IMPORTED,
'description' => 'Indicates current status of the source row',
];
$fields['rollback_action'] = [
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => MigrateIdMapInterface::ROLLBACK_DELETE,
'description' => 'Flag indicating what to do for this item on rollback',
];
$fields['last_imported'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'UNIX timestamp of the last time this row was imported',
'size' => 'big',
];
$fields['hash'] = [
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
];
$map_table_schema = [
'description' => 'Mappings from source identifier value(s) to destination identifier value(s).',
'fields' => $fields,
'primary key' => [
'source_ids_hash',
],
'indexes' => [
'source' => [
'sourceid1',
'sourceid2',
],
],
];
// Now do the message table.
$fields = [];
$fields['msgid'] = [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
];
$fields['source_ids_hash'] = [
'type' => 'varchar',
'length' => 64,
'not null' => 1,
'description' => 'Hash of source ids. Used as primary key',
];
$fields['level'] = [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
];
$fields['message'] = [
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
];
$table_schema = [
'description' => 'Messages generated during a migration process',
'fields' => $fields,
'primary key' => [
'msgid',
],
'indexes' => [
'source_ids_hash' => [
'source_ids_hash',
],
],
];
$schema = $this->prophesize('Drupal\\Core\\Database\\Schema');
$schema->tableExists('migrate_map_sql_idmap_test')
->willReturn(FALSE);
$schema->tableExists('migrate_message_sql_idmap_test')
->willReturn(FALSE);
$schema->createTable('migrate_map_sql_idmap_test', $map_table_schema)
->shouldBeCalled();
$schema->createTable('migrate_message_sql_idmap_test', $table_schema)
->shouldBeCalled();
$this->runEnsureTablesTest($schema->reveal());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.