function 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.

7 calls to DrupalWebTestCase::checkPermissions()
DrupalWebTestCase::drupalCreateContentType in modules/simpletest/drupal_web_test_case.php
Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateRole in modules/simpletest/drupal_web_test_case.php
Creates a role with specified permissions.
DrupalWebTestCase::resetAll in modules/simpletest/drupal_web_test_case.php
Reset all data structures after having enabled new modules.
FilterDefaultFormatTestCase::resetFilterCaches in modules/filter/filter.test
Rebuilds text format and permission caches in the thread running the tests.
FilterFormatAccessTestCase::resetFilterCaches in modules/filter/filter.test
Rebuilds text format and permission caches in the thread running the tests.

... See full list

File

modules/simpletest/drupal_web_test_case.php, line 1313

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.