Commit 5d29f324 authored by webchick's avatar webchick
Browse files

Issue #2256317 by sun: Remove static caching from WebTestBase::checkPermissions().

parent 971735da
......@@ -47,7 +47,6 @@ function setUp() {
'name' => 'Full HTML',
));
$full_html_format->save();
$this->checkPermissions(array(), TRUE);
// Create and log in an administrative user having access to the Full HTML
// text format.
......
......@@ -61,8 +61,6 @@ function setupBundle() {
content_translation_set_config('comment', 'node__comment_article', 'enabled', TRUE);
// Refresh entity info.
entity_info_cache_clear();
// Flush the permissions after adding the translatable comment bundle.
$this->checkPermissions(array(), TRUE);
}
/**
......
......@@ -83,6 +83,5 @@ function testDefaultTextFormats() {
*/
protected function resetFilterCaches() {
filter_formats_reset();
$this->checkPermissions(array(), TRUE);
}
}
......@@ -330,6 +330,5 @@ function testFormatWidgetPermissions() {
*/
protected function resetFilterCaches() {
filter_formats_reset();
$this->checkPermissions(array(), TRUE);
}
}
......@@ -55,7 +55,6 @@ function setUp() {
$filtered_html_format->save();
// Setup users.
$this->checkPermissions(array(), TRUE);
$this->web_user = $this->drupalCreateUser(array(
'access content',
'access comments',
......
......@@ -247,9 +247,6 @@ protected function enableService($resource_type, $method = 'GET', $format = NULL
protected function rebuildCache() {
// Rebuild routing cache, so that the REST API paths are available.
$this->container->get('router.builder')->rebuild();
// Reset the Simpletest permission cache, so that the new resource
// permissions get picked up.
drupal_static_reset('checkPermissions');
}
/**
......
......@@ -335,10 +335,6 @@ protected function drupalCreateContentType(array $values = array()) {
$this->assertEqual($status, SAVED_NEW, String::format('Created content type %type.', array('%type' => $type->id())));
// Reset permissions so that permissions for this content type are
// available.
$this->checkPermissions(array(), TRUE);
return $type;
}
......@@ -663,23 +659,16 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL
}
/**
* Check to make sure that the array of permissions are valid.
* Checks whether a given list of permission names is valid.
*
* @param $permissions
* Permissions to check.
* @param $reset
* Reset cached available permissions.
* @param array $permissions
* The permission names to check.
*
* @return
* TRUE or FALSE depending on whether the permissions are valid.
* @return bool
* TRUE if the permissions are valid, FALSE otherwise.
*/
protected function checkPermissions(array $permissions, $reset = FALSE) {
$available = &drupal_static(__FUNCTION__);
if (!isset($available) || $reset) {
$available = array_keys(\Drupal::moduleHandler()->invokeAll('permission'));
}
protected function checkPermissions(array $permissions) {
$available = array_keys(\Drupal::moduleHandler()->invokeAll('permission'));
$valid = TRUE;
foreach ($permissions as $permission) {
if (!in_array($permission, $available)) {
......@@ -1132,7 +1121,6 @@ protected function resetAll() {
// Reset static variables and reload permissions.
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
}
/**
......
......@@ -27,9 +27,6 @@ function testVocabularyPermissionsTaxonomyTerm() {
// Vocabulary used for creating, removing and editing terms.
$vocabulary = $this->createVocabulary();
// Reset to permission static cache to get proper permissions.
$this->checkPermissions(array(), TRUE);
// Test as admin user.
$user = $this->drupalCreateUser(array('administer taxonomy'));
$this->drupalLogin($user);
......
......@@ -226,7 +226,6 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
);
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
filter_formats_reset();
$this->checkPermissions(array(), TRUE);
$format = entity_load('filter_format', $edit['format']);
$format_id = $format->format;
$permission = $format->getPermissionName();
......
......@@ -64,7 +64,6 @@ function setUp() {
$this->full_html_format->save();
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($this->filtered_html_format->getPermissionName()));
$this->checkPermissions(array(), TRUE);
// Create regular and administrative users.
$this->web_user = $this->drupalCreateUser(array('post comments'));
......
......@@ -64,7 +64,6 @@ protected function enableViewsTestModule() {
$query->values($record);
}
$query->execute();
$this->checkPermissions(array(), TRUE);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment