table.test in Migrate 7.2
Same filename and directory in other branches
Tests for the table destination plugin.
File
tests/plugins/destinations/table.testView source
<?php
/**
* @file
* Tests for the table destination plugin.
*/
/**
* Test table migration.
*/
class MigrateTableUnitTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Table migration',
'description' => 'Test migration of table data',
'group' => 'Migrate',
);
}
function setUp() {
parent::setUp('migrate', 'migrate_example');
// Make sure the migrations are registered.
migrate_static_registration();
}
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'));
}
}
Classes
Name | Description |
---|---|
MigrateTableUnitTest | Test table migration. |