You are here

public function SearchByPageExtraUsersTest::setUp in Search by Page 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

tests/search_by_page.test, line 951
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageExtraUsersTest
Tests that no extra Search by Page indexing users are created.

Code

public function setUp() {
  parent::setUp('search', 'search_by_page', 'sbp_nodes', 'sbp_test', 'dblog', 'comment');
  $this
    ->setUpEnvironments();

  // Set up super-user.
  $this->superuser = $this
    ->drupalCreateUser(array(
    'administer nodes',
    'access content',
    'administer content types',
    'administer blocks',
    'administer search',
    'search content',
    'administer search by page',
    'access administration pages',
    $this
      ->searchPerm($this->envinfo1),
    'administer site configuration',
    'administer users',
    'administer permissions',
    'view test private content',
    'access site reports',
    'access comments',
    'skip comment approval',
    'administer comments',
  ));
  $this
    ->drupalLogin($this->superuser);

  // Set up so "sbp_indexed" nodes are searchable.
  // Index them with the super-user.
  $this
    ->drupalPost('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'sbp_nodes_types_indexed[sbp_indexed]' => TRUE,
    'sbp_nodes_display_type' => 'excerpts',
    'sbp_nodes_role' => $this
      ->getNewRoleID($this->superuser),
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  cache_clear_all('variables', 'cache_bootstrap');
  variable_initialize();

  // Create 5 nodes with the same content.
  $info = array(
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 'blah',
        ),
      ),
    ),
    'type' => 'sbp_indexed',
    'language' => LANGUAGE_NONE,
    'title' => 'blah',
    'test_private' => FALSE,
  );
  $this->nodes = array();
  for ($i = 0; $i < 5; $i++) {
    $this->nodes[] = $this
      ->drupalCreateNode($info);
  }

  // Run cron to index these nodes.
  $this
    ->doCronrun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
  $this
    ->drupalLogout();
}