You are here

function MigrateImportOptionsTest::testItemLimitOption in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 tests/import/options.test \MigrateImportOptionsTest::testItemLimitOption()

File

tests/import/options.test, line 23

Class

MigrateImportOptionsTest
Test node migration.

Code

function testItemLimitOption() {
  $migration = Migration::getInstance('BeerTerm');
  $limit = 1;
  $options = array(
    'limit' => array(
      'unit' => 'item',
      'value' => $limit,
    ),
  );

  // We use the timers to track how many times prepareRow() is called.
  global $timers, $_migrate_track_timer;
  $_migrate_track_timer = TRUE;
  $result = $migration
    ->processImport($options);
  $this
    ->verbose(print_r($timers, 1));
  $successes = $migration
    ->importedCount();
  $this
    ->verbose("Total successes: {$successes}");
  $assertion = format_plural($limit, 'The migration successfully processed 1 item.', 'The migration successfully processed @count items.');
  $this
    ->assertEqual($limit, $successes, $assertion);
  $prepare_row_count = $timers['BeerTermMigration prepareRow']['count'];
  $this
    ->verbose("prepareRow() count: {$prepare_row_count}");
  $processed = $migration
    ->processedCount();
  $this
    ->verbose("Total processed count: {$processed}");
  $assertion = format_plural($processed, 'The migration executed processRow() on 1 item.', 'The migration executed processRow() on @count items.');
  $this
    ->assertEqual($prepare_row_count, $processed, $assertion);
}