You are here

public function SearchByPageTesterTest::getNewRoleID in Search by Page 8

Returns the unique role ID created by the testing framework.

15 calls to SearchByPageTesterTest::getNewRoleID()
SearchbyPageAttach2Test::setUp in tests/src/Functional/search_by_page.test
SearchByPageAttachTest::setUp in tests/src/Functional/search_by_page.test
SearchByPageExtraUsersTest::setUp in tests/src/Functional/search_by_page.test
SearchByPageIntlTest::setupPath in tests/src/Functional/search_by_page.test
Sets up SBP Paths with a path to index.
SearchByPageNodesReindexTest::setUp in tests/src/Functional/search_by_page.test

... See full list

File

tests/src/Functional/SearchByPageTesterTest.php, line 121
General Functional Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageTesterTest
Base class for testing Search by Page.

Namespace

Drupal\Tests\search_by_page\Functional

Code

public function getNewRoleID($account) {
  $roles = $account->roles;
  $allroles = user_roles();
  foreach ($roles as $id => $name) {
    if ($id != AccountInterface::ANONYMOUS_ROLE && $id != AccountInterface::AUTHENTICATED_ROLE) {
      $this
        ->assertTrue(isset($allroles[$id]) && $allroles[$id], 'Found a role for new user and it exists');
      return $id;
    }
  }
  $this
    ->fail('Did not find a new role for new user');
  return AccountInterface::ANONYMOUS_ROLE;
}