public function OgMigrate7000TestCase::testUser in Organic groups 7.2
Test user upgrade.
See also
og_7000_user()
File
- ./
og.test, line 1018
Class
- OgMigrate7000TestCase
- Upgrade 7000 test.
Code
public function testUser() {
// Assert users.
$values = array(
// Uid 3 is the group manager, so in OG6 it was marked as admin.
3 => array(
'admin' => TRUE,
),
4 => array(
'active' => FALSE,
),
5 => array(),
6 => array(
'active' => FALSE,
'admin' => TRUE,
),
7 => array(
'admin' => TRUE,
),
);
$og_roles = og_roles('node', 'test_group');
foreach ($values as $uid => $value) {
$account = user_load($uid);
// Set default values.
$value += array(
'active' => TRUE,
'admin' => FALSE,
);
$roles = array();
if ($value['active']) {
$op = 'active';
$states = array(
OG_STATE_ACTIVE,
);
$rid = array_search(OG_AUTHENTICATED_ROLE, $og_roles);
}
else {
$op = 'pending';
$states = array(
OG_STATE_PENDING,
);
// If the member is pending then they have the anonymous role.
$rid = array_search(OG_ANONYMOUS_ROLE, $og_roles);
}
$roles[$rid] = TRUE;
if ($value['admin']) {
// OG_ADMINISTRATOR_ROLE
$rid = array_search(OG_ADMINISTRATOR_ROLE, $og_roles);
$roles[$rid] = TRUE;
}
$this
->assertTrue(og_is_member('node', 10, 'user', $account, $states), format_string('User @uid is @op member in group.', array(
'@uid' => $uid,
'@op' => $op,
)));
// Pass also pending state, so we make sure that even if the user
// isn't active they are considered members, to check they get the
// correct role.
$this
->assertEqual(array_keys(og_get_user_roles('node', 10, $uid, TRUE, FALSE)), array_keys($roles), format_string('User @uid has the correct roles in group.', array(
'@uid' => $uid,
)));
}
}