You are here

function MigrateTableUnitTest::testTableImport in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 tests/plugins/destinations/table.test \MigrateTableUnitTest::testTableImport()

File

tests/plugins/destinations/table.test, line 28
Tests for the table destination plugin.

Class

MigrateTableUnitTest
Test table migration.

Code

function testTableImport() {
  $migration = Migration::getInstance('WineTable');
  $result = $migration
    ->processImport();
  $this
    ->assertEqual($result, Migration::RESULT_COMPLETED, t('Table import returned RESULT_COMPLETED'));
  $result = db_query("SELECT COUNT(*)\n       FROM {migrate_example_wine_table_source} s\n       INNER JOIN {migrate_map_winetable} map ON s.fooid=map.sourceid1\n       INNER JOIN {migrate_example_wine_table_dest} d ON map.destid1=d.recordid");
  $this
    ->assertEqual($result
    ->fetchField(), 3, t('Count of imported records is correct'));

  // Test rollback
  $result = $migration
    ->processRollback();
  $this
    ->assertEqual($result, Migration::RESULT_COMPLETED, t('Variety term rollback returned RESULT_COMPLETED'));
  $result = db_query("SELECT COUNT(*) FROM {migrate_example_wine_table_dest}");
  $this
    ->assertEqual($result
    ->fetchField(), 0, t('All migrated rows removed'));
  $result = db_query("SELECT COUNT(*) FROM {migrate_map_winetable}");
  $this
    ->assertEqual($result
    ->fetchField(), 0, t('All map rows removed'));
}