You are here

protected function FilterHtmlImageSecureTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/filter/src/Tests/FilterHtmlImageSecureTest.php \Drupal\filter\Tests\FilterHtmlImageSecureTest::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/FilterHtmlImageSecureTest.php, line 37
Contains \Drupal\filter\Tests\FilterHtmlImageSecureTest.

Class

FilterHtmlImageSecureTest
Tests restriction of IMG tags in HTML input.

Namespace

Drupal\filter\Tests

Code

protected function setUp() {
  parent::setUp();

  // Setup Filtered HTML text format.
  $filtered_html_format = entity_create('filter_format', array(
    'format' => 'filtered_html',
    'name' => 'Filtered HTML',
    'filters' => array(
      'filter_html' => array(
        'status' => 1,
        'settings' => array(
          'allowed_html' => '<img src testattribute> <a>',
        ),
      ),
      'filter_autop' => array(
        'status' => 1,
      ),
      'filter_html_image_secure' => array(
        'status' => 1,
      ),
    ),
  ));
  $filtered_html_format
    ->save();

  // Setup users.
  $this->webUser = $this
    ->drupalCreateUser(array(
    'access content',
    'access comments',
    'post comments',
    'skip comment approval',
    $filtered_html_format
      ->getPermissionName(),
  ));
  $this
    ->drupalLogin($this->webUser);

  // Setup a node to comment and test on.
  $this
    ->drupalCreateContentType(array(
    'type' => 'page',
    'name' => 'Basic page',
  ));

  // Add a comment field.
  $this
    ->addDefaultCommentField('node', 'page');
  $this->node = $this
    ->drupalCreateNode();
}