options.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Tests for import options.
  5. */
  6. /**
  7. * Test node migration.
  8. */
  9. class MigrateImportOptionsTest extends DrupalWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Import options',
  13. 'description' => 'Test the import options',
  14. 'group' => 'Migrate',
  15. );
  16. }
  17. function setUp() {
  18. parent::setUp('migrate_example');
  19. // Make sure the migrations are registered.
  20. migrate_static_registration();
  21. }
  22. function testItemLimitOption() {
  23. $migration = Migration::getInstance('BeerTerm');
  24. $limit = 1;
  25. $options = array(
  26. 'limit' => array(
  27. 'unit' => 'item',
  28. 'value' => $limit,
  29. ),
  30. );
  31. // We use the timers to track how many times prepareRow() is called.
  32. global $timers, $_migrate_track_timer;
  33. $_migrate_track_timer = TRUE;
  34. $result = $migration->processImport($options);
  35. $successes = $migration->importedCount();
  36. $assertion = format_plural($limit, 'The migration successfully processed 1 item.',
  37. 'The migration successfully processed @count items.');
  38. $this->assertEqual($limit, $successes, $assertion);
  39. $prepare_row_count = $timers['BeerTermMigration prepareRow']['count'];
  40. $processed = $migration->processedCount();
  41. $assertion = format_plural($processed, 'The migration executed processRow() on 1 item.',
  42. 'The migration executed processRow() on @count items.');
  43. $this->assertEqual($prepare_row_count, $processed, $assertion);
  44. }
  45. }