function SimplenewsRolesTestCase::testRoleSync in Simplenews Roles 6
Same name and namespace in other branches
- 6.2 tests/simplenews_roles.test \SimplenewsRolesTestCase::testRoleSync()
Test role synchronization.
File
- tests/
simplenews_roles.test, line 25
Class
- SimplenewsRolesTestCase
- Unit tests for Simplenews Roles module.
Code
function testRoleSync() {
$user = $this
->drupalCreateUser($permissions = NULL);
// We want the role that's just been created for this user by drupalCreateUser
// It's almost certainly role 3.
// To be sure we should say array_shift($roles) but STUPID POS PHP resets
// numerical keys after an array_shift, WTF.
// This should be safe though. Thanks catch!
$rid = max(array_keys($user->roles));
$rids = array(
$rid,
);
// Get a newsletter.
$tid = $this
->getRandomNewsletter();
// synchronize the role and the newsletter.
simplenews_roles_update_subscriptions($tid, $rids);
$this
->assertTrue(simplenews_user_is_subscribed($user->mail, $tid, TRUE), t('User with role was automatically subscribed.'));
}