You are here

public function MigrateSqlIdMapEnsureTablesTest::testEnsureTablesExist in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 129
Contains \Drupal\Tests\migrate\Unit\MigrateSqlIdMapEnsureTablesTest.

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
    ->at(0))
    ->method('tableExists')
    ->with('migrate_map_sql_idmap_test')
    ->will($this
    ->returnValue(TRUE));
  $schema
    ->expects($this
    ->at(1))
    ->method('fieldExists')
    ->with('migrate_map_sql_idmap_test', 'rollback_action')
    ->will($this
    ->returnValue(FALSE));
  $field_schema = array(
    'type' => 'int',
    'size' => 'tiny',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'description' => 'Flag indicating what to do for this item on rollback',
  );
  $schema
    ->expects($this
    ->at(2))
    ->method('addField')
    ->with('migrate_map_sql_idmap_test', 'rollback_action', $field_schema);
  $schema
    ->expects($this
    ->at(3))
    ->method('fieldExists')
    ->with('migrate_map_sql_idmap_test', 'hash')
    ->will($this
    ->returnValue(FALSE));
  $field_schema = array(
    'type' => 'varchar',
    'length' => '64',
    'not null' => FALSE,
    'description' => 'Hash of source row data, for detecting changes',
  );
  $schema
    ->expects($this
    ->at(4))
    ->method('addField')
    ->with('migrate_map_sql_idmap_test', 'hash', $field_schema);
  $schema
    ->expects($this
    ->exactly(5))
    ->method($this
    ->anything());
  $this
    ->runEnsureTablesTest($schema);
}