function SqlTest::testFailEnsureTables

Same name in other branches
  1. 10 core/modules/migrate/tests/src/Kernel/Plugin/id_map/SqlTest.php \Drupal\Tests\migrate\Kernel\Plugin\id_map\SqlTest::testFailEnsureTables()
  2. 11.x core/modules/migrate/tests/src/Kernel/Plugin/id_map/SqlTest.php \Drupal\Tests\migrate\Kernel\Plugin\id_map\SqlTest::testFailEnsureTables()

Tests exception is thrown in ensureTables fails.

@dataProvider providerTestFailEnsureTables

File

core/modules/migrate/tests/src/Kernel/Plugin/id_map/SqlTest.php, line 140

Class

SqlTest
Tests that the migrate map table is created.

Namespace

Drupal\Tests\migrate\Kernel\Plugin\id_map

Code

public function testFailEnsureTables($ids) {
    // This just tests mysql, as other PDO integrations allow longer indexes.
    if (Database::getConnection()->databaseType() !== 'mysql') {
        $this->markTestSkipped("This test only runs for MySQL");
    }
    $this->migrationDefinition['source']['ids'] = $ids;
    $migration = $this->container
        ->get('plugin.manager.migration')
        ->createStubMigration($this->migrationDefinition);
    // Use local id map plugin to force an error.
    $map = new SqlIdMapTest($this->database, [], 'test', [], $migration, $this->eventDispatcher, $this->migrationPluginManager);
    $this->expectException(DatabaseExceptionWrapper::class);
    $this->expectExceptionMessage("Syntax error or access violation: 1074 Column length too big for column 'sourceid1' (max = 16383); use BLOB or TEXT instead:");
    $map->ensureTables();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.