public function MigrateSqlIdMapTest::testDestroy in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testDestroy()
Tests the destroy method.
Scenarios to test for:
- No errors.
- One error.
- Multiple errors.
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 968
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testDestroy() {
$id_map = $this
->getIdMap();
// Initialize the ID map.
$id_map
->getDatabase();
$map_table_name = $id_map
->mapTableName();
$message_table_name = $id_map
->messageTableName();
$row = new Row([
'source_id_property' => 'source_value',
], [
'source_id_property' => [],
]);
$id_map
->saveIdMapping($row, [
'destination_id_property' => 2,
]);
$id_map
->saveMessage([
'source_id_property' => 'source_value',
], 'A message');
$this
->assertTrue($this->database
->schema()
->tableExists($map_table_name), "{$map_table_name} exists");
$this
->assertTrue($this->database
->schema()
->tableExists($message_table_name), "{$message_table_name} exists");
$id_map
->destroy();
$this
->assertFalse($this->database
->schema()
->tableExists($map_table_name), "{$map_table_name} does not exist");
$this
->assertFalse($this->database
->schema()
->tableExists($message_table_name), "{$message_table_name} does not exist");
}