You are here

public function SearchByPagePathsNodesTest::setUp in Search by Page 6

Same name and namespace in other branches
  1. 7 tests/search_by_page.test \SearchByPagePathsNodesTest::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 1377
Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPagePathsNodesTest
Tests for Search by Page Paths - searching nodes.

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 blocks',
    'administer search',
    'search content',
    'administer search by page',
    'access administration pages',
    $this
      ->searchPerm($this->envinfo2),
    'administer site configuration',
    'administer users',
    'administer permissions',
    'administer filters',
    'access site reports',
  ));
  $this
    ->drupalLogin($this->superuser);

  // Set up Search by Page button name
  $this
    ->drupalPost('admin/settings/search_by_page/edit/' . $this->envid2, array(
    'button_label' => t('Search pages'),
  ), 'Save configuration');
  cache_clear_all('variables', 'cache');
  variable_init();

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

  // Create some content with different input formats and add to SBP Paths.
  // Also verify that menu_execute_active_handler() can find the pages.
  $info = array(
    'body' => 'I walk through the streets, looking around for trouble',
    'teaser' => 'I walk on a path, where it is quiet',
    'type' => 'page',
    'format' => 1,
  );
  $node = $this
    ->drupalCreateNode($info);
  $content = menu_execute_active_handler('node/' . $node->nid);
  $this
    ->assertTrue($content, "First node content is not empty");
  $this
    ->assertFalse(is_int($content), "First node content is not an integer");
  $path_add_path = 'admin/settings/search_by_page/edit/' . $this->envid2 . '/paths/add';
  $this
    ->drupalPost($path_add_path, array(
    'path' => 'node/' . $node->nid,
    'title' => t($node->title),
    'type' => t('Page'),
    'snippet' => 'yes',
    'role' => $this
      ->getNewRoleID($this->superuser),
  ), 'Create new indexed page');
  $info = array(
    'body' => 'I can walk really far, maybe even to the north pole.',
    'teaser' => 'I will walk to the south pole.',
    'type' => 'page',
    'format' => 2,
  );
  $node = $this
    ->drupalCreateNode($info);
  $content = menu_execute_active_handler('node/' . $node->nid);
  $this
    ->assertTrue($content, "Second node content is not empty");
  $this
    ->assertFalse(is_int($content), "Second node content is not an integer");
  $this
    ->drupalPost($path_add_path, array(
    'path' => 'node/' . $node->nid,
    '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');
  $this
    ->drupalLogout();
}