You are here

protected function QuickEditLoadingTest::setUp in Quick Edit 7

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

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

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.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

./quickedit.test, line 28
Tests loading of Quick Edit and lazy-loading of in-place editors.

Class

QuickEditLoadingTest
Tests loading of Quick Edit and lazy-loading of in-place editors.

Code

protected function setUp() {

  // Block module is necessary for regions to show up, and hence for
  // hook_page_build() to be able to #attach something in Drupal 7.
  parent::setUp(array(
    'block',
    'contextual',
    'quickedit',
    'filter',
    'node',
  ));

  // Bartik theme alters comment links, so use a different theme.
  theme_enable(array(
    'bartik',
  ));
  variable_set('theme_default', 'bartik');

  // Create a text format.
  $filtered_html_format = new stdClass();
  $filtered_html_format->format = 'filtered_html';
  $filtered_html_format->name = 'Filtered HTML';
  $filtered_html_format->filters = array();
  filter_format_save($filtered_html_format);

  // Create a node type.
  $this
    ->drupalCreateContentType(array(
    'type' => 'article',
    'name' => 'Article',
  ));

  // Create one node of the above node type using the above text format.
  $this
    ->drupalCreateNode(array(
    'type' => 'article',
    'title' => '<script>alert("EVIL!")</script>',
    'body' => array(
      LANGUAGE_NONE => array(
        0 => array(
          'value' => '<p>How are you?</p>',
          'format' => 'filtered_html',
        ),
      ),
    ),
    'log' => $this
      ->randomString(),
    'promote' => 1,
  ));

  // Create 2 users, the only difference being the ability to use in-place
  // editing
  $basic_permissions = array(
    'access content',
    'create article content',
    'edit any article content',
    'use text format filtered_html',
    'access contextual links',
  );
  $this->author_user = $this
    ->drupalCreateUser($basic_permissions);
  $this->editor_user = $this
    ->drupalCreateUser(array_merge($basic_permissions, array(
    'access in-place editing',
  )));
}