You are here

public function SearchByPageTester::setUpEnvironments in Search by Page 7

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

Creates two environments for Search by Page.

18 calls to SearchByPageTester::setUpEnvironments()
SearchbyPageAttach2Test::setUp in tests/search_by_page.test
Sets up a Drupal site for running functional and integration tests.
SearchbyPageAttachNotReadable::setUp in tests/search_by_page.test
Sets up a Drupal site for running functional and integration tests.
SearchbyPageAttachReindexTest::setUp in tests/search_by_page.test
Sets up a Drupal site for running functional and integration tests.
SearchByPageAttachTest::setUp in tests/search_by_page.test
Sets up a Drupal site for running functional and integration tests.
SearchByPageEnvironmentTest::setUp in tests/search_by_page.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

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

Class

SearchByPageTester
Base class for testing Search by Page.

Code

public function setUpEnvironments() {
  $user = $this
    ->drupalCreateUser(array(
    'administer search by page',
    'access administration pages',
    'administer site configuration',
    'administer search',
  ));
  $this
    ->drupalLogin($user);

  // Content access permissions always need to be rebuilt for some reason.
  node_access_rebuild();

  // Verify this module is active in Search.
  $active = variable_get('search_active_modules', array(
    'node',
    'user',
  ));
  $this
    ->assertTrue(in_array('search_by_page', $active));

  // Clear out any existing search environments that may have been defined.
  $envs = search_by_page_list_environments();
  foreach ($envs as $env) {
    module_invoke_all('sbp_delete_environment', $env);
  }

  // Define two new environments. They should have ID numbers 1 and 2.
  $this->envinfo1 = array(
    'environment_name' => 'env1',
    'set_as_default' => 1,
    'page_title' => t('Search page 1 title'),
    'block_title' => t('Search block 1 title'),
    'field_label' => t('Search field 1 label'),
    'button_label' => t('Search button 1 label'),
    'page_path' => 'search_path_1',
    'exclude_tags' => 'tagtoexclude',
  );
  $this
    ->drupalPost('admin/config/search/search_by_page/add', $this->envinfo1, 'Save configuration');
  $this->envid1 = 1;
  $this->envinfo2 = array(
    'environment_name' => 'env2',
    'set_as_default' => 2,
    'page_title' => t('Search page 2 title'),
    'block_title' => t('Search block 2 title'),
    'field_label' => t('Search field 2 label'),
    'button_label' => t('Search button 2 label'),
    'page_path' => 'search_path_2',
  );
  $this
    ->drupalPost('admin/config/search/search_by_page/add', $this->envinfo2, 'Save configuration');
  $this->envid2 = 2;

  // Reset the SimpleTest permissions cache.
  $this
    ->checkPermissions(array(), TRUE);
  $this
    ->drupalLogout();
}