You are here

public function OgUiMigrate7000TestCase::testUpgrade in Organic groups 7.2

Test a successful upgrade.

File

og_ui/og_ui.test, line 487

Class

OgUiMigrate7000TestCase
Upgrade 7000 test.

Code

public function testUpgrade() {

  // Assert according to the scenario Drupal 6's test table dump was created.
  $nodes_info = array(
    // Open group.
    1 => array(
      'name' => t('open'),
      'anon' => array(
        'subscribe' => FALSE,
        'subscribe without approval' => TRUE,
      ),
    ),
    // Moderated group.
    2 => array(
      'name' => t('moderated'),
      'anon' => array(
        'subscribe' => TRUE,
        'subscribe without approval' => FALSE,
      ),
    ),
    // Invite only group.
    3 => array(
      'name' => t('invite only'),
      'anon' => array(
        'subscribe' => FALSE,
        'subscribe without approval' => FALSE,
      ),
    ),
    // Closed group.
    4 => array(
      'name' => t('closed'),
      'anon' => array(
        'subscribe' => FALSE,
        'subscribe without approval' => FALSE,
      ),
      'auth' => array(
        'unsubscribe' => FALSE,
      ),
    ),
  );
  foreach ($nodes_info as $nid => $node_info) {

    // Set default values.
    $node_info += array(
      'auth' => array(
        'unsubscribe' => TRUE,
      ),
    );
    $og_roles = og_roles('node', 'test_group', $nid, TRUE);
    $permissions = og_role_permissions($og_roles);
    $anon_rid = array_search(OG_ANONYMOUS_ROLE, $og_roles);
    $auth_rid = array_search(OG_AUTHENTICATED_ROLE, $og_roles);

    // Assert permissions for non-member and member roles.
    $this
      ->assertEqual($permissions[$anon_rid], array_filter($node_info['anon']), t('Correct permissions were set for non-member role in @type group.', array(
      '@type' => $node_info['name'],
    )));
    $this
      ->assertEqual($permissions[$auth_rid], array_filter($node_info['auth']), t('Correct permissions were set for member role in @type group.', array(
      '@type' => $node_info['name'],
    )));
  }
}