You are here

public function OgMigrate7000TestCase::testogMigrateUpgradeGroup in Organic groups 7

Test a successful group upgrade.

File

og_migrate/og_migrate.test, line 55

Class

OgMigrate7000TestCase
Upgrade 7000 test.

Code

public function testogMigrateUpgradeGroup() {

  // Run the required migration.
  $edit = array(
    'migrate[upgrade_group]' => TRUE,
    'migrate[upgrade_group_content]' => TRUE,
  );
  $this
    ->drupalPost('admin/config/group/group-migrate', $edit, t('Migrate'));

  // Assert according to the scenario Drupal 6's test table dump was created.
  // TODO: Assert OG fields.
  $group = og_get_group('node', 1);
  $this
    ->assertEqual($group->state, OG_STATE_ACTIVE, t('Node ID 1 is an active group.'));
  $group = og_get_group('node', 2);
  $this
    ->assertEqual($group->state, OG_STATE_ACTIVE, t('Node ID 2 is an active group.'));

  // Test group content with NID 3 - 5 belong to the group with NID 2.
  foreach (range(3, 5) as $nid) {
    $node = node_load($nid);
    $this
      ->assertTrue(og_is_member($group->gid, 'node', $node), t('Node ID @nid is a group content of Node ID 2', array(
      '@nid' => $nid,
    )));
  }

  // Orphan group content (i.e. not attached to a group).
  $group = og_get_group('node', 6);
  $this
    ->assertFalse($group, t('Node ID 6 is not a group.'));
  $node = node_load(6);
  $this
    ->assertFalse($node->{OG_AUDIENCE_FIELD}, t('Node ID 6 is not associated with a group.'));

  // Group content that shares the same group.
  $group_alpha = og_get_group('node', 7);
  $group_beta = og_get_group('node', 8);
  $node = node_load(9);
  foreach (array(
    $group_alpha,
    $group_beta,
  ) as $group) {
    $this
      ->assertTrue(og_is_member($group->gid, 'node', $node), t('Node ID @nid is as group content associated with multiple groups.', array(
      '@nid' => $node->nid,
    )));
  }
}