You are here

function OgMigrate7200TestCase::testUpgrade in Organic groups 7.2

File

./og.test, line 1361

Class

OgMigrate7200TestCase
Test Upgrade from branch 1.x to 2.x.

Code

function testUpgrade() {
  $this
    ->assertTrue($this
    ->performUpgrade(), t('The upgrade was completed successfully.'));
  $this
    ->assertFalse(field_info_field('group_audience'), 'Group audience field was deleted.');

  // spl_autoload_register() wasn't called, so we do it here, to allow
  // classes to be auto-loaded.
  spl_autoload_register('drupal_autoload_class');
  spl_autoload_register('drupal_autoload_interface');
  module_enable(array(
    'og',
    'migrate',
  ));

  // FIXME: migrate_flush_caches() crashes, so we register manually.
  MigrationBase::registerMigration('OgMigrateMembership');
  MigrationBase::registerMigration('OgMigrateRoles');
  MigrationBase::registerMigration('OgMigrateUserRoles');
  $migration = Migration::getInstance('OgMigrateMembership');
  $result = $migration
    ->processImport();
  $this
    ->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateMembership returned RESULT_COMPLETED');
  $migration = Migration::getInstance('OgMigrateRoles');
  $result = $migration
    ->processImport();
  $this
    ->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateRoles returned RESULT_COMPLETED');
  $migration = Migration::getInstance('OgMigrateUserRoles');
  $result = $migration
    ->processImport();
  $this
    ->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateUserRoles returned RESULT_COMPLETED');

  // Assert group roles.
  $roles = array(
    'non-member',
    'member',
    'administrator member',
  );
  $this
    ->assertEqual(array_values(og_roles('node', 'school', 1)), $roles, 'Returned expected roles group first group.');
  $roles[] = 'new role';
  $this
    ->assertEqual(array_values(og_roles('node', 'school', 2)), $roles, 'Returned expected roles group second group.');

  // Assert field name was registered in the OG membership.
  $og_membership = entity_load_single('og_membership', 1);
  $this
    ->assertTrue($og_membership->field_name, 'Field name was registered in the OG membership.');
}