table.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the table destination plugin.
  5. */
  6. /**
  7. * Test table migration.
  8. */
  9. class MigrateTableUnitTest extends DrupalWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Table migration',
  13. 'description' => 'Test migration of table data',
  14. 'group' => 'Migrate',
  15. );
  16. }
  17. function setUp() {
  18. parent::setUp('migrate', 'migrate_example');
  19. }
  20. function testTableImport() {
  21. $migration = Migration::getInstance('WineTable');
  22. $result = $migration->processImport();
  23. $this->assertEqual($result, Migration::RESULT_COMPLETED,
  24. t('Table import returned RESULT_COMPLETED'));
  25. $result = db_query(
  26. "SELECT COUNT(*)
  27. FROM {migrate_example_wine_table_source} s
  28. INNER JOIN {migrate_map_winetable} map ON s.fooid=map.sourceid1
  29. INNER JOIN {migrate_example_wine_table_dest} d ON map.destid1=d.recordid"
  30. );
  31. $this->assertEqual($result->fetchField(), 3,
  32. t('Count of imported records is correct'));
  33. // Test rollback
  34. $result = $migration->processRollback();
  35. $this->assertEqual($result, Migration::RESULT_COMPLETED,
  36. t('Variety term rollback returned RESULT_COMPLETED'));
  37. $result = db_query("SELECT COUNT(*) FROM {migrate_example_wine_table_dest}");
  38. $this->assertEqual($result->fetchField(), 0, t('All migrated rows removed'));
  39. $result = db_query("SELECT COUNT(*) FROM {migrate_map_winetable}");
  40. $this->assertEqual($result->fetchField(), 0, t('All map rows removed'));
  41. }
  42. }