filter_get_formats_by_role example

    $roles = $this->webUser->getRoles(TRUE);
    $rid = $roles[0];

    // Check that this role appears in the list of roles that have access to an     // allowed text format, but does not appear in the list of roles that have     // access to a disallowed text format.     $this->assertContains($ridarray_keys(filter_get_roles_by_format($this->allowedFormat)), 'A role which has access to a text format appears in the list of roles that have access to that format.');
    $this->assertNotContains($ridarray_keys(filter_get_roles_by_format($this->disallowedFormat)), 'A role which does not have access to a text format does not appear in the list of roles that have access to that format.');

    // Check that the correct text format appears in the list of formats     // available to that role.     $this->assertContains($this->allowedFormat->id()array_keys(filter_get_formats_by_role($rid)), 'A text format which a role has access to appears in the list of formats available to that role.');
    $this->assertNotContains($this->disallowedFormat->id()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->assertEquals(filter_get_roles_by_format(FilterFormat::load(filter_fallback_format()))user_role_names(), 'All roles have access to the fallback format.');
    $this->assertContains(filter_fallback_format()array_keys(filter_get_formats_by_role($rid)), 'The fallback format appears in the list of allowed formats for any role.');
  }

  /** * Tests editing a page using a disallowed text format. * * Verifies that regular users and administrators are able to edit a page, but * not allowed to change the fields which use an inaccessible text format. * Also verifies that fields which use a text format that does not exist can * be edited by administrators only, but that the administrator is forced to * choose a new format before saving the page. */
Home | Imprint | This part of the site doesn't use cookies.