You are here

public function SearchByPagePathsAliasTest::setUp in Search by Page 7

Same name and namespace in other branches
  1. 6 tests/search_by_page.test \SearchByPagePathsAliasTest::setUp()

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 1838
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPagePathsAliasTest
Tests for Search by Page Paths - searching nodes with aliases.

Code

public function setUp() {
  parent::setUp('search', 'search_by_page', 'sbp_paths', 'sbp_test', 'path', 'dblog');
  $this
    ->setUpEnvironments();
  $this->superuser = $this
    ->drupalCreateUser(array(
    'administer nodes',
    'access content',
    'administer blocks',
    'administer search',
    'search content',
    'administer search by page',
    'access administration pages',
    $this
      ->searchPerm($this->envinfo1),
    'administer site configuration',
    'administer users',
    'administer permissions',
    'administer url aliases',
    'create url aliases',
    'access site reports',
  ));
  $this
    ->drupalLogin($this->superuser);

  // Set up Search by Page button name
  $this
    ->drupalPost('admin/config/search/search_by_page/edit/' . $this->envid1, array(
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  cache_clear_all('variables', 'cache_bootstrap');
  variable_initialize();

  // Throw in a few nodes that won't match our tests.
  $info = array(
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 'blah',
          'summary' => 'blah',
        ),
      ),
    ),
    'title' => 'blah',
    'language' => LANGUAGE_NONE,
  );
  $this
    ->drupalCreateNode($info);
  $this
    ->drupalCreateNode($info);
  $this
    ->drupalCreateNode($info);
  $this
    ->drupalCreateNode($info);

  // Create some content with a path alias and add to SBP Paths.
  // Create the content.
  $info = array(
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 'I walk through the streets, looking around for trouble',
          'summary' => 'I walk on a path, where it is quiet',
        ),
      ),
    ),
    'type' => 'page',
    'language' => LANGUAGE_NONE,
  );
  $node = $this
    ->drupalCreateNode($info);

  // Add a URL alias to the system.
  $alias = $this
    ->randomName();
  $this
    ->drupalPost('admin/config/search/path/add', array(
    'source' => 'node/' . $node->nid,
    'alias' => $alias,
  ), t('Save'));

  // Add it to Search by Page Paths.
  $path_add_path = 'admin/config/search/search_by_page/edit/' . $this->envid1 . '/paths/add';
  $this
    ->drupalPost($path_add_path, array(
    'path' => $alias,
    'title' => t($node->title),
    'type' => t('Page'),
    'snippet' => 'yes',
    'role' => $this
      ->getNewRoleID($this->superuser),
  ), 'Create new indexed page');
  $this
    ->doCronRun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');
}