You are here

function SimplenewsRolesTestCase::getRandomNewsletter in Simplenews Roles 6.2

Select randomly one of the available newsletters. Copied from simplenews.test.

Return value

newsletter tid.

1 call to SimplenewsRolesTestCase::getRandomNewsletter()
SimplenewsRolesTestCase::testRoleSync in tests/simplenews_roles.test
Test role synchronization.

File

tests/simplenews_roles.test, line 31

Class

SimplenewsRolesTestCase
Unit tests for Simplenews Roles module.

Code

function getRandomNewsletter() {
  if ($taxonomies = taxonomy_get_tree(variable_get('simplenews_vid', ''))) {
    $tids = array();
    foreach ($taxonomies as $newsletter) {
      $tids[] = $newsletter->tid;
    }
    $key = array_rand($tids);
    return $tids[$key];
  }
  return 0;
}