You are here

protected function FilterAdminTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/filter/src/Tests/FilterAdminTest.php \Drupal\filter\Tests\FilterAdminTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/filter/src/Tests/FilterAdminTest.php, line 47
Contains \Drupal\filter\Tests\FilterAdminTest.

Class

FilterAdminTest
Thoroughly test the administrative interface of the filter module.

Namespace

Drupal\filter\Tests

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType(array(
    'type' => 'page',
    'name' => 'Basic page',
  ));

  // Set up the filter formats used by this test.
  $basic_html_format = entity_create('filter_format', array(
    'format' => 'basic_html',
    'name' => 'Basic HTML',
    'filters' => array(
      'filter_html' => array(
        'status' => 1,
        'settings' => array(
          'allowed_html' => '<p> <br> <strong> <a> <em>',
        ),
      ),
    ),
  ));
  $basic_html_format
    ->save();
  $restricted_html_format = entity_create('filter_format', array(
    'format' => 'restricted_html',
    'name' => 'Restricted HTML',
    'filters' => array(
      'filter_html' => array(
        'status' => TRUE,
        'weight' => -10,
        'settings' => array(
          'allowed_html' => '<p> <br> <strong> <a> <em> <h4>',
        ),
      ),
      'filter_autop' => array(
        'status' => TRUE,
        'weight' => 0,
      ),
      'filter_url' => array(
        'status' => TRUE,
        'weight' => 0,
      ),
      'filter_htmlcorrector' => array(
        'status' => TRUE,
        'weight' => 10,
      ),
    ),
  ));
  $restricted_html_format
    ->save();
  $full_html_format = entity_create('filter_format', array(
    'format' => 'full_html',
    'name' => 'Full HTML',
    'weight' => 1,
    'filters' => array(),
  ));
  $full_html_format
    ->save();
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'administer filters',
    $basic_html_format
      ->getPermissionName(),
    $restricted_html_format
      ->getPermissionName(),
    $full_html_format
      ->getPermissionName(),
    'access site reports',
  ));
  $this->webUser = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit own page content',
  ));
  user_role_grant_permissions('authenticated', array(
    $basic_html_format
      ->getPermissionName(),
  ));
  user_role_grant_permissions('anonymous', array(
    $restricted_html_format
      ->getPermissionName(),
  ));
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalPlaceBlock('local_actions_block');
}