Commit a8d45429 authored by alexpott's avatar alexpott

Issue #2012312 by tim.plunkett: Remove legacy code from filter.module.

parent 9d5cb43e
......@@ -53,7 +53,7 @@ function setUp() {
// text format.
$this->adminUser = $this->drupalCreateUser(array(
'administer blocks',
filter_permission_name($full_html_format),
$full_html_format->getPermissionName(),
'access administration pages',
));
$this->drupalLogin($this->adminUser);
......
......@@ -47,7 +47,7 @@ function hook_ckeditor_plugin_info_alter(array &$plugins) {
* @param $editor
* The text editor object as returned by editor_load(), for which these files
* are being loaded. Based on this information, it is possible to load the
* corresponding text format object as returned by filter_format_load().
* corresponding text format object.
*
* @see _ckeditor_theme_css()
*/
......
......@@ -7,15 +7,17 @@ editor_field_untransformed_text:
requirements:
_permission: 'access in-place editing'
_access_edit_entity_field: 'TRUE'
editor_image_dialog:
pattern: '/editor/dialog/image/{filter_format}'
defaults:
_form: '\Drupal\editor\Form\EditorImageDialog'
requirements:
_filter_access: 'TRUE'
_entity_access: 'filter_format.view'
editor_link_dialog:
pattern: '/editor/dialog/link/{filter_format}'
defaults:
_form: '\Drupal\editor\Form\EditorLinkDialog'
requirements:
_filter_access: 'TRUE'
_entity_access: 'filter_format.view'
......@@ -71,7 +71,7 @@ public function id() {
* Overrides Drupal\Core\Entity\Entity::label().
*/
public function label($langcode = NULL) {
$format = filter_format_load($this->format);
$format = entity_load('filter_format', $this->format);
return $format->name;
}
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ filter_tips:
defaults:
_content: '\Drupal\filter\Controller\FilterController::filterTips'
requirements:
_filter_access: 'TRUE'
_entity_access: 'filter_format.view'
filter_admin_overview:
pattern: '/admin/config/content/formats'
......@@ -38,5 +38,8 @@ filter_admin_disable:
pattern: '/admin/config/content/formats/manage/{filter_format}/disable'
defaults:
_entity_form: 'filter_format.disable'
options:
_access_mode: 'ALL'
requirements:
_filter_disable_format_access: 'TRUE'
_permission: 'administer filters'
......@@ -10,10 +10,6 @@ services:
class: Drupal\filter\Access\FormatDisableCheck
tags:
- { name: access_check }
access_check.filter_access:
class: Drupal\filter\Access\FilterAccessCheck
tags:
- { name: access_check }
plugin.manager.filter:
class: Drupal\filter\FilterPluginManager
arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@module_handler']
<?php
/**
* @file
* Contains \Drupal\filter\Access\FilterAccessCheck.
*/
namespace Drupal\filter\Access;
use Drupal\Core\Access\StaticAccessCheckInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Checks access for text formats.
*/
class FilterAccessCheck implements StaticAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_filter_access');
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
if ($format = $request->attributes->get('filter_format')) {
// Handle special cases up front. All users have access to the fallback
// format.
if ($format->format == filter_fallback_format()) {
return static::ALLOW;
}
// Check the permission if one exists; otherwise, we have a non-existent
// format so we return FALSE.
$permission = filter_permission_name($format);
return !empty($permission) && user_access($permission) ? static::ALLOW : static::DENY;
}
}
}
......@@ -24,14 +24,11 @@ public function appliesTo() {
}
/**
* Implements \Drupal\Core\Access\AccessCheckInterface::access().
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
if ($format = $request->attributes->get('filter_format')) {
return (user_access('administer filters') && ($format->format != filter_fallback_format())) ? static::ALLOW : static::DENY;
}
return static::DENY;
$format = $request->attributes->get('filter_format');
return ($format && !$format->isFallbackFormat()) ? static::ALLOW : static::DENY;
}
}
......@@ -239,7 +239,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
// Note: user_role_change_permissions() triggers a call chain back into
// filter_permission() and lastly filter_formats(), so its cache must be
// reset upfront.
if (($roles = $this->get('roles')) && $permission = filter_permission_name($this)) {
if (($roles = $this->get('roles')) && $permission = $this->getPermissionName()) {
foreach (user_roles() as $rid => $name) {
$enabled = in_array($rid, $roles, TRUE);
user_role_change_permissions($rid, array($permission => $enabled));
......@@ -261,4 +261,11 @@ public function isFallbackFormat() {
return $this->id() == $fallback_format;
}
/**
* {@inheritdoc}
*/
public function getPermissionName() {
return !$this->isFallbackFormat() ? 'use text format ' . $this->id() : FALSE;
}
}
......@@ -26,21 +26,21 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
return TRUE;
}
if (user_access('administer filters', $account)) {
if ($operation != 'view' && $account->hasPermission('administer filters')) {
return TRUE;
}
// Check the permission if one exists; otherwise, we have a non-existent
// format so we return FALSE.
$permission = filter_permission_name($entity);
return !empty($permission) && user_access($permission, $account);
$permission = $entity->getPermissionName();
return !empty($permission) && $account->hasPermission($permission);
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return user_access('administer filters', $account);
return $account->hasPermission('administer filters');
}
}
......@@ -78,7 +78,7 @@ public function form(array $form, array &$form_state) {
'#default_value' => $format->id(),
'#maxlength' => 255,
'#machine_name' => array(
'exists' => 'filter_format_exists',
'exists' => array($this, 'exists'),
'source' => array('name'),
),
'#disabled' => !$format->isNew(),
......@@ -196,6 +196,22 @@ public function form(array $form, array &$form_state) {
return parent::form($form, $form_state);
}
/**
* Determines if the format already exists.
*
* @param string $format_id
* The format ID
*
* @return bool
* TRUE if the format exists, FALSE otherwise.
*/
public function exists($format_id) {
return (bool) $this->queryFactory
->get('filter_format')
->condition('format', $format_id)
->execute();
}
/**
* {@inheritdoc}
*/
......@@ -241,7 +257,7 @@ public function submit(array $form, array &$form_state) {
$format->save();
// Save user permissions.
if ($permission = filter_permission_name($format)) {
if ($permission = $format->getPermissionName()) {
foreach ($form_state['values']['roles'] as $rid => $enabled) {
user_role_change_permissions($rid, array($permission => $enabled));
}
......
......@@ -49,4 +49,13 @@ public function setFilterConfig($instance_id, array $configuration);
*/
public function isFallbackFormat();
/**
* Returns the machine-readable permission name for the text format.
*
* @return string|bool
* The machine-readable permission name, or FALSE if the text format is
* malformed or is the fallback format (which is available to all users).
*/
public function getPermissionName();
}
......@@ -198,7 +198,7 @@ function testTypedDataAPI() {
$this->assertTrue($data instanceof AllowedValuesInterface, 'Typed data object implements \Drupal\Core\TypedData\AllowedValuesInterface');
$filtered_html_user = $this->createUser(array('uid' => 2), array(
filter_permission_name(filter_format_load('filtered_html')),
entity_load('filter_format', 'filtered_html')->getPermissionName(),
));
// Test with anonymous user.
......
......@@ -34,14 +34,14 @@ function setUp() {
parent::setUp();
// Create users.
$basic_html_format = filter_format_load('basic_html');
$restricted_html_format = filter_format_load('restricted_html');
$full_html_format = filter_format_load('full_html');
$basic_html_format = entity_load('filter_format', 'basic_html');
$restricted_html_format = entity_load('filter_format', 'restricted_html');
$full_html_format = entity_load('filter_format', 'full_html');
$this->admin_user = $this->drupalCreateUser(array(
'administer filters',
filter_permission_name($basic_html_format),
filter_permission_name($restricted_html_format),
filter_permission_name($full_html_format),
$basic_html_format->getPermissionName(),
$restricted_html_format->getPermissionName(),
$full_html_format->getPermissionName(),
));
$this->web_user = $this->drupalCreateUser(array('create page content', 'edit own page content'));
......@@ -143,8 +143,9 @@ function testFilterAdmin() {
$this->assertResponse(403, 'The fallback format cannot be disabled.');
// Verify access permissions to Full HTML format.
$this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), 'Admin user may use Full HTML.');
$this->assertFalse(filter_access(filter_format_load($full), $this->web_user), 'Web user may not use Full HTML.');
$full_format = entity_load('filter_format', $full);
$this->assertTrue($full_format->access('view', $this->admin_user), 'Admin user may use Full HTML.');
$this->assertFalse($full_format->access('view', $this->web_user), 'Web user may not use Full HTML.');
// Add an additional tag.
$edit = array();
......@@ -199,7 +200,7 @@ function testFilterAdmin() {
$this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), 'New filter created.');
filter_formats_reset();
$format = filter_format_load($edit['format']);
$format = entity_load('filter_format', $edit['format']);
$this->assertNotNull($format, 'Format found in database.');
$this->drupalGet('admin/config/content/formats/manage/' . $format->format);
$this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', 'Role found.');
......@@ -212,7 +213,7 @@ function testFilterAdmin() {
$this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), 'Format successfully disabled.');
// Allow authenticated users on full HTML.
$format = filter_format_load($full);
$format = entity_load('filter_format', $full);
$edit = array();
$edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 0;
$edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
......
......@@ -39,7 +39,6 @@ function testTextFormatCrud() {
$format->name = 'Empty format';
$format->save();
$this->verifyTextFormat($format);
$this->verifyFilters($format);
// Add another text format specifying all possible properties.
$format = entity_create('filter_format', array());
......@@ -53,7 +52,6 @@ function testTextFormatCrud() {
));
$format->save();
$this->verifyTextFormat($format);
$this->verifyFilters($format);
// Alter some text format properties and save again.
$format->name = 'Altered format';
......@@ -65,7 +63,6 @@ function testTextFormatCrud() {
));
$format->save();
$this->verifyTextFormat($format);
$this->verifyFilters($format);
// Add a uncacheable filter and save again.
$format->setFilterConfig('filter_test_uncacheable', array(
......@@ -73,7 +70,6 @@ function testTextFormatCrud() {
));
$format->save();
$this->verifyTextFormat($format);
$this->verifyFilters($format);
// Disable the text format.
$format->disable()->save();
......@@ -89,8 +85,8 @@ function verifyTextFormat($format) {
$t_args = array('%format' => $format->name);
$default_langcode = language_default()->id;
// Verify filter_format_load().
$filter_format = filter_format_load($format->format);
// Verify the loaded filter has all properties.
$filter_format = entity_load('filter_format', $format->format);
$this->assertEqual($filter_format->format, $format->format, format_string('filter_format_load: Proper format id for text format %format.', $t_args));
$this->assertEqual($filter_format->name, $format->name, format_string('filter_format_load: Proper title for text format %format.', $t_args));
$this->assertEqual($filter_format->cache, $format->cache, format_string('filter_format_load: Proper cache indicator for text format %format.', $t_args));
......@@ -99,9 +95,8 @@ function verifyTextFormat($format) {
$this->assertEqual($format->langcode, $default_langcode, format_string('filter_format_load: Proper language code for text format %format.', $t_args));
// Verify the 'cache' text format property according to enabled filters.
$filters = filter_list_format($filter_format->format);
$cacheable = TRUE;
foreach ($filters as $name => $filter) {
foreach ($format->filters() as $name => $filter) {
// If this filter is not cacheable, update $cacheable accordingly, so we
// can verify $format->cache after iterating over all filters.
if ($filter->status && !$filter->cache) {
......@@ -112,25 +107,4 @@ function verifyTextFormat($format) {
$this->assertEqual($filter_format->cache, $cacheable, 'Text format contains proper cache property.');
}
/**
* Verifies that filters are properly stored for a text format.
*/
function verifyFilters($format) {
$filters = filter_list_format($format->format);
$format_filters = $format->filters();
foreach ($filters as $name => $filter) {
$t_args = array('%format' => $format->name, '%filter' => $name);
// Verify that filter status is properly stored.
$this->assertEqual($filter->status, $format_filters->get($name)->status, format_string('filter_list_format: Proper status for %filter in text format %format.', $t_args));
// Verify that filter settings were properly stored.
$this->assertEqual($filter->settings, $format_filters->get($name)->settings, format_string('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args));
// Verify that each filter has a module name assigned.
$this->assertTrue(!empty($filter->module), format_string('filter_list_format: Proper module name for %filter in text format %format.', $t_args));
}
$this->assertEqual(count($filters), count($format_filters), 'filter_list_format: All filters for the format are present.');
}
}
......@@ -41,7 +41,7 @@ function setUp() {
*/
function testInstallation() {
// Verify that the format was installed correctly.
$format = filter_format_load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertTrue((bool) $format);
$this->assertEqual($format->id(), 'filter_test');
$this->assertEqual($format->label(), 'Test format');
......@@ -82,7 +82,7 @@ function testInstallation() {
*/
function testUpdateRoles() {
// Verify role permissions declared in default config.
$format = filter_format_load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
DRUPAL_ANONYMOUS_RID,
DRUPAL_AUTHENTICATED_RID,
......@@ -95,7 +95,7 @@ function testUpdateRoles() {
$format->save();
// Verify that roles have not been updated.
$format = filter_format_load('filter_test');
$format = entity_load('filter_format', 'filter_test');
$this->assertEqual(array_keys(filter_get_roles_by_format($format)), array(
DRUPAL_ANONYMOUS_RID,
DRUPAL_AUTHENTICATED_RID,
......
......@@ -37,11 +37,12 @@ function testDefaultTextFormats() {
);
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = filter_format_load($edit['format']);
$formats[] = entity_load('filter_format', $edit['format']);
}
list($first_format, $second_format) = $formats;
$first_user = $this->drupalCreateUser(array(filter_permission_name($first_format), filter_permission_name($second_format)));
$second_user = $this->drupalCreateUser(array(filter_permission_name($second_format)));
$second_format_permission = $second_format->getPermissionName();
$first_user = $this->drupalCreateUser(array($first_format->getPermissionName(), $second_format_permission));
$second_user = $this->drupalCreateUser(array($second_format_permission));
// Adjust the weights so that the first and second formats (in that order)
// are the two lowest weighted formats available to any user.
......
......@@ -88,7 +88,7 @@ function setUp() {
);
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
$this->resetFilterCaches();
$formats[] = filter_format_load($edit['format']);
$formats[] = entity_load('filter_format', $edit['format']);
}
list($this->allowed_format, $this->second_allowed_format, $this->disallowed_format) = $formats;
$this->drupalLogout();
......@@ -97,8 +97,8 @@ function setUp() {
$this->web_user = $this->drupalCreateUser(array(
'create page content',
'edit any page content',
filter_permission_name($this->allowed_format),
filter_permission_name($this->second_allowed_format),
$this->allowed_format->getPermissionName(),
$this->second_allowed_format->getPermissionName(),
));
// Create an administrative user who has access to use all three formats.
......@@ -106,9 +106,9 @@ function setUp() {
'administer filters',
'create page content',
'edit any page content',
filter_permission_name($this->allowed_format),
filter_permission_name($this->second_allowed_format),
filter_permission_name($this->disallowed_format),
$this->allowed_format->getPermissionName(),
$this->second_allowed_format->getPermissionName(),
$this->disallowed_format->getPermissionName(),
));
}
......@@ -118,9 +118,10 @@ function setUp() {
function testFormatPermissions() {
// Make sure that a regular user only has access to the text formats for
// which they were granted access.
$this->assertTrue(filter_access($this->allowed_format, $this->web_user), 'A regular user has access to a text format they were granted access to.');
$this->assertFalse(filter_access($this->disallowed_format, $this->web_user), 'A regular user does not have access to a text format they were not granted access to.');
$this->assertTrue(filter_access(filter_format_load(filter_fallback_format()), $this->web_user), 'A regular user has access to the fallback format.');
$fallback_format = entity_load('filter_format', filter_fallback_format());
$this->assertTrue($this->allowed_format->access('view', $this->web_user), 'A regular user has access to a text format they were granted access to.');
$this->assertFalse($this->disallowed_format->access('view', $this->web_user), 'A regular user does not have access to a text format they were not granted access to.');
$this->assertTrue($fallback_format->access('view', $this->web_user), 'A regular user has access to the fallback format.');
// Perform similar checks as above, but now against the entire list of
// available formats for this user.
......@@ -130,8 +131,8 @@ function testFormatPermissions() {
// Make sure that a regular user only has permission to use the format
// they were granted access to.
$this->assertTrue(user_access(filter_permission_name($this->allowed_format), $this->web_user), 'A regular user has permission to use the allowed text format.');
$this->assertFalse(user_access(filter_permission_name($this->disallowed_format), $this->web_user), 'A regular user does not have permission to use the disallowed text format.');
$this->assertTrue(user_access($this->allowed_format->getPermissionName(), $this->web_user), 'A regular user has permission to use the allowed text format.');
$this->assertFalse(user_access($this->disallowed_format->getPermissionName(), $this->web_user), 'A regular user does not have permission to use the disallowed text format.');
// Make sure that the allowed format appears on the node form and that
// the disallowed format does not.
......@@ -192,7 +193,7 @@ function testFormatRoles() {
$this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_get_formats_by_role($rid))), 'A text format which a role does not have access to does not appear in the list of formats available to that role.');
// Check that the fallback format is always allowed.
$this->assertEqual(filter_get_roles_by_format(filter_format_load(filter_fallback_format())), user_role_names(), 'All roles have access to the fallback format.');
$this->assertEqual(filter_get_roles_by_format(entity_load('filter_format', filter_fallback_format())), user_role_names(), 'All roles have access to the fallback format.');
$this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid))), 'The fallback format appears in the list of allowed formats for any role.');
}
......@@ -292,7 +293,7 @@ function testFormatWidgetPermissions() {
$this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertUrl('node/' . $node->id());
foreach (filter_formats() as $format) {
if ($format->format != filter_fallback_format()) {
if (!$format->isFallbackFormat()) {
$format->disable()->save();
}
}
......
......@@ -61,7 +61,7 @@ function setUp() {
'access comments',
'post comments',
'skip comment approval',
filter_permission_name($filtered_html_format),
$filtered_html_format->getPermissionName(),
));
$this->drupalLogin($this->web_user);
......
......@@ -56,7 +56,7 @@ function setUp() {
));
$filtered_html_format->save();
$filtered_html_permission = filter_permission_name($filtered_html_format);
$filtered_html_permission = $filtered_html_format->getPermissionName();
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($filtered_html_permission));
$this->admin_user = $this->drupalCreateUser(array('administer modules', 'administer filters', 'administer site configuration'));
......
......@@ -62,7 +62,7 @@ function testFilterDefaults() {
filter_formats_reset();
// Verify that saved filter settings have not been changed.
foreach (filter_list_format($filter_defaults_format->format) as $name => $filter) {
foreach ($filter_defaults_format->filters() as $name => $filter) {
$this->assertEqual($filter->weight, $saved_settings[$name]['weight'], format_string('@name filter weight %saved equals %previous', array(
'@name' => $name,
'%saved' => $filter->weight,
......
......@@ -26,7 +26,7 @@ public static function getInfo() {
*/
function testPhpFilter() {
// Log in as a user with permission to use the PHP code text format.
$php_code_permission = filter_permission_name(filter_format_load('php_code'));
$php_code_permission = entity_load('filter_format', 'php_code')->getPermissionName();
$web_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content', $php_code_permission));
$this->drupalLogin($web_user);
......
......@@ -35,11 +35,11 @@ function setUp() {
// Verify that the PHP code text format was inserted.
$php_format_id = 'php_code';
$this->php_code_format = filter_format_load($php_format_id);
$this->php_code_format = entity_load('filter_format', $php_format_id);
$this->assertEqual($this->php_code_format->name, 'PHP code', 'PHP code text format was created.');
// Verify that the format has the PHP code filter enabled.
$filters = filter_list_format($php_format_id);
$filters = $this->php_code_format->filters();
$this->assertTrue($filters->get('php_code')->status, 'PHP code filter is enabled.');
// Verify that the format exists on the administration page.
......
......@@ -38,10 +38,10 @@ function setUp() {
// Create and log in an administrative user having access to the Full HTML
// text format.
$full_html_format = filter_format_load('full_html');
$full_html_format = entity_load('filter_format', 'full_html');
$permissions = array(
'administer filters',
filter_permission_name($full_html_format),
$full_html_format->getPermissionName(),
'administer permissions',
'create page content',
'skip comment approval',
......
......@@ -35,7 +35,7 @@ function setUp() {
));
$filtered_html_format->save();
$filtered_html_permission = filter_permission_name($filtered_html_format);
$filtered_html_permission = $filtered_html_format->getPermissionName();
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($filtered_html_permission));
}
......
......@@ -41,16 +41,14 @@ public function testFilterFormatUpgrade() {
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
// Checks that all the formats were upgraded
$one = filter_format_load('format_one');
$one = entity_load('filter_format', 'format_one');
$this->assertTrue(!empty($one), 'Filter Format one was successfully upgraded');
$two = filter_format_load('format_two');
$two = entity_load('filter_format', 'format_two');
$this->assertTrue(!empty($two), 'Filter Format two was successfully upgraded');
// Filter format 'Three' is disabled, and filter_format_load should return
// FALSE. However the entity should be accessible using entity_load.
$three_disabled = filter_format_load('format_three');
// Filter format 'Three' is disabled.
$three_entity = entity_load('filter_format', 'format_three');
$this->assertTrue(empty($three_disabled) && !empty($three_entity), 'Filter Format three was successfully upgraded and it is disabled');
$this->assertFalse($three_entity->status(), 'Filter Format three was successfully upgraded and it is disabled');
// Check the access to the text formats.
......@@ -75,7 +73,7 @@ public function testFilterFormatUpgrade() {
$this->assertNoFieldChecked('edit-5-use-text-format-format-two', 'Use text format format_two permission for role is set correctly.');
// Check that the format has the missing filter.
$two = filter_format_load('format_two');
$two = entity_load('filter_format', 'format_two');
$this->assertTrue($two->filters()->has('missing_filter'));
// Try to use a filter format with a missing filter, this should not throw
......@@ -88,7 +86,7 @@ public function testFilterFormatUpgrade() {
$this->assertRaw(t('The %filter filter is missing, and will be removed once this format is saved.', array('%filter' => 'missing_filter')));
$this->drupalPost(NULL, array(), t('Save configuration'));
filter_formats_reset();
$two = filter_format_load('format_two');
$two = entity_load('filter_format', 'format_two');
$this->assertFalse($two->filters()->has('missing_filter'));
}
......
......@@ -188,7 +188,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
// Disable all text formats besides the plain text fallback format.
$this->drupalLogin($this->admin_user);
foreach (filter_formats() as $format) {
if ($format->format != filter_fallback_format()) {
if (!$format->isFallbackFormat()) {
$this->drupalPost('admin/config/content/formats/manage/' . $format->format . '/disable', array(), t('Disable'));
}
}
......@@ -230,9 +230,9 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
filter_formats_reset();
$this->checkPermissions(array(), TRUE);
$format = filter_format_load($edit['format']);
$format = entity_load('filter_format', $edit['format']);
$format_id = $format->format;
$permission = filter_permission_name($format);
$permission = $format->getPermissionName();
$roles = $this->web_user->getRoles();
$rid = $roles[0];
user_role_grant_permissions($rid, array($permission));
......
......@@ -120,7 +120,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
// Retrieve the filters of the specified text format, if any.
if (isset($format)) {
$filters = filter_list_format($format);
$filters = entity_load('filter_format', $format)->filters();
// If the specified format does not exist, return nothing. $text is already
// filtered text, but the remainder of this function will not be able to
// ensure a sane and secure summary.
......
......@@ -62,7 +62,7 @@ function setUp() {
));
$this->full_html_format->save();
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(filter_permission_name($this->filtered_html_format)));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($this->filtered_html_format->getPermissionName()));
$this->checkPermissions(array(), TRUE);
// Create regular and administrative users.
......@@ -70,7 +70,7 @@ function setUp() {
$admin_permissions = array('administer comments');
foreach (filter_formats() as $format) {
if ($permission = filter_permission_name($format)) {
if ($permission = $format->getPermissionName()) {
$admin_permissions[] = $permission;
}
}
......
......@@ -37,6 +37,7 @@ protected function setUp() {
parent::setUp();
$this->installConfig(array('system', 'filter'));
$this->installSchema('user', array('users'));
}
public function testAreaText() {
......