You are here

protected function DrupalWebTestCase::checkPermissions in SimpleTest 7.2

Same name and namespace in other branches
  1. 6.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.

4 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.
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 1136
Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.

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;
}