You are here

protected function DrupalWebTestCase::checkPermissions in SimpleTest 7

Same name and namespace in other branches
  1. 6.2 drupal_web_test_case.php \DrupalWebTestCase::checkPermissions()
  2. 7.2 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::setUp in ./drupal_web_test_case.php
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…

File

./drupal_web_test_case.php, line 929

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function checkPermissions(array $permissions, $reset = FALSE) {
  $available =& drupal_static(__FUNCTION__);
  if (!isset($available) || $reset) {
    $available = array_keys(module_invoke_all('permission'));
  }
  $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;
}