function MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist()
  3. 11.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist()

Tests the ensureTables method when the tables exist.

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php, line 139

Class

MigrateSqlIdMapEnsureTablesTest
Tests the SQL ID map plugin ensureTables() method.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testEnsureTablesExist() {
    $schema = $this->getMockBuilder('Drupal\\Core\\Database\\Schema')
        ->disableOriginalConstructor()
        ->getMock();
    $schema->expects($this->exactly(1))
        ->method('tableExists')
        ->with('migrate_map_sql_idmap_test')
        ->willReturn(TRUE);
    $schema->expects($this->exactly(3))
        ->method('fieldExists')
        ->willReturnMap([
        [
            'migrate_map_sql_idmap_test',
            'rollback_action',
            FALSE,
        ],
        [
            'migrate_map_sql_idmap_test',
            'hash',
            FALSE,
        ],
        [
            'migrate_map_sql_idmap_test',
            'source_ids_hash',
            FALSE,
        ],
    ]);
    $schema->expects($this->exactly(3))
        ->method('addField')
        ->withConsecutive([
        'migrate_map_sql_idmap_test',
        'rollback_action',
        [
            'type' => 'int',
            'size' => 'tiny',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'default' => 0,
            'description' => 'Flag indicating what to do for this item on rollback',
        ],
    ], [
        'migrate_map_sql_idmap_test',
        'hash',
        [
            'type' => 'varchar',
            'length' => '64',
            'not null' => FALSE,
            'description' => 'Hash of source row data, for detecting changes',
        ],
    ], [
        'migrate_map_sql_idmap_test',
        'source_ids_hash',
        [
            'type' => 'varchar',
            'length' => '64',
            'not null' => TRUE,
            'description' => 'Hash of source ids. Used as primary key',
        ],
    ]);
    $this->runEnsureTablesTest($schema);
}

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