You are here

protected function DrupalWebTestCase::checkPermissions in SimpleTest 6.2

Same name and namespace in other branches
  1. 7.2 drupal_web_test_case.php \DrupalWebTestCase::checkPermissions()
  2. 7 drupal_web_test_case.php \DrupalWebTestCase::checkPermissions()

Check to make sure that the array of permissions are valid.

Parameters

$permissions: Permissions to check.

$reset: Reset cached available permissions.

Return value

TRUE or FALSE depending on whether the permissions are valid.

3 calls to DrupalWebTestCase::checkPermissions()
DrupalWebTestCase::drupalCreateContentType in ./drupal_web_test_case.php
Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateRole in ./drupal_web_test_case.php
Internal helper function; Create a role with specified permissions.
DrupalWebTestCase::resetAll in ./drupal_web_test_case.php
Reset all data structures after having enabled new modules.

File

./drupal_web_test_case.php, line 1103

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function checkPermissions(array $permissions, $reset = FALSE) {
  static $available;
  if (!isset($available) || $reset) {
    $available = module_invoke_all('perm');
  }
  $valid = TRUE;
  foreach ($permissions as $permission) {
    if (!in_array($permission, $available)) {
      $this
        ->fail(t('Invalid permission %permission.', array(
        '%permission' => $permission,
      )), t('Role'));
      $valid = FALSE;
    }
  }
  return $valid;
}