$this->disallowedFormat->
getPermissionName(),
]);
$this->
drupalPlaceBlock('local_tasks_block'
);
} /**
* Tests the Filter format access permissions functionality.
*/
public function testFormatPermissions() { // Make sure that a regular user only has access to the text formats for
// which they were granted access.
$fallback_format = FilterFormat::
load(filter_fallback_format());
$disallowed_format_name =
$this->disallowedFormat->
getPermissionName();
$this->
assertTrue($this->allowedFormat->
access('use',
$this->webUser
), 'A regular user has access to use a text format they were granted access to.'
);
$this->
assertEquals(AccessResult::
allowed()->
addCacheContexts(['user.permissions'
]),
$this->allowedFormat->
access('use',
$this->webUser, TRUE
), 'A regular user has access to use a text format they were granted access to.'
);
$this->
assertFalse($this->disallowedFormat->
access('use',
$this->webUser
), 'A regular user does not have access to use a text format they were not granted access to.'
);
$this->
assertEquals(AccessResult::
neutral("The '
$disallowed_format_name' permission is required."
)->
cachePerPermissions(),
$this->disallowedFormat->
access('use',
$this->webUser, TRUE
), 'A regular user does not have access to use a text format they were not granted access to.'
);
$this->
assertTrue($fallback_format->
access('use',
$this->webUser
), 'A regular user has access to use the fallback format.'
);
$this->
assertEquals(AccessResult::
allowed(),
$fallback_format->
access('use',
$this->webUser, TRUE
), 'A regular user has access to use the fallback format.'
);
// Perform similar checks as above, but now against the entire list of
// available formats for this user.
$this->
assertContains($this->allowedFormat->
id(),
array_keys(filter_formats($this->webUser
)), 'The allowed format appears in the list of available formats for a regular user.'
);