You are here

public function SearchByPagePathsRemoveTest::setUp in Search by Page 6

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

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

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

File

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

Class

SearchByPagePathsRemoveTest
Functionality test for removing paths from Search by Page Paths.

Code

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

  // Set up indexing of pages.
  $this
    ->drupalPost('admin/settings/search_by_page/edit/' . $this->envid1, array(
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  $path_add_path = 'admin/settings/search_by_page/edit/' . $this->envid1 . '/paths/add';
  $this
    ->drupalPost($path_add_path, array(
    'path' => 'sbp_test_priv_page',
    'title' => t("Private page"),
    'type' => t('Page'),
    'snippet' => 'yes',
    'role' => $this
      ->getNewRoleID($this->privuser),
  ), 'Create new indexed page');
  $this
    ->drupalPost($path_add_path, array(
    'path' => 'sbp_test_pub_page',
    'title' => t("Public page"),
    'type' => t('Page'),
    'snippet' => 'yes',
    'role' => $this
      ->getNewRoleID($this->noprivuser),
  ), 'Create new indexed page');
  $this
    ->drupalPost($path_add_path, array(
    'path' => 'sbp_test_another_page',
    'title' => t("Public page"),
    'type' => t('Page'),
    'snippet' => t('Trees: Orange and Lemon'),
    'role' => $this
      ->getNewRoleID($this->noprivuser),
  ), 'Create new indexed page');
  cache_clear_all('variables', 'cache');
  variable_init();
  $this
    ->doCronrun();
  $this
    ->drupalLogin($this->superuser);
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertText(t('Cron run completed'), 'Log shows cron run completed');

  // Assuming that the regular tests worked, we know at this point that
  // these pages will have been indexed. So now remove two of the pages
  // from SBP Paths, and we'll test that they can no longer be found.
  $this
    ->drupalLogin($this->superuser);
  $path_del_path = 'admin/settings/search_by_page/edit/' . $this->envid1 . '/paths/delete/';
  $this
    ->drupalPost($path_del_path . '1', array(), t('Confirm'));
  $this
    ->drupalPost($path_del_path . '2', array(), t('Confirm'));
}