You are here

function DrupalSolrOfflineSearchPagesWebTestCase::testNewAndRemoveSearchPage in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 tests/apachesolr_base.test \DrupalSolrOfflineSearchPagesWebTestCase::testNewAndRemoveSearchPage()
  2. 6.3 tests/apachesolr_base.test \DrupalSolrOfflineSearchPagesWebTestCase::testNewAndRemoveSearchPage()

Asserts that we can edit a search environment

File

tests/apachesolr_base.test, line 347
Unit test class that provides tests for base functionality of the Apachesolr Module without having the need of a Solr Server

Class

DrupalSolrOfflineSearchPagesWebTestCase
@file Unit test class that provides tests for base functionality of the Apachesolr Module without having the need of a Solr Server

Code

function testNewAndRemoveSearchPage() {

  // Create a new search page
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('admin/config/search/apachesolr/search-pages');
  $this
    ->assertText(t('Add search page'), t('Create new search page link is available'));
  $this
    ->clickLink(t('Add search page'));
  $this
    ->assertText(t('The human-readable name of the search page configuration.'), t('Search page creation page successfully added'));
  $edit = array(
    'page_id' => 'solr_testingsuite',
    'env_id' => 'solr',
    'label' => 'Test Search Page',
    'description' => 'Test Description',
    'page_title' => 'Test Title',
    'search_path' => 'search/searchdifferentpath',
  );
  $this
    ->drupalPost($this
    ->getUrl(), $edit, t('Save'));
  $this
    ->assertResponse(200);

  // Make sure the menu is recognized
  drupal_static_reset('apachesolr_search_load_all_search_pages');
  menu_cache_clear_all();
  menu_rebuild();
  $this
    ->drupalGet('admin/config/search/apachesolr/search-pages');
  $this
    ->assertText(t('Test Search Page'), t('Search Page was successfully created'));

  // Remove the same environment
  $this
    ->clickLink(t('Delete'));
  $this
    ->assertText(t('search page configuration will be deleted.This action cannot be undone.'), t('Delete confirmation page was successfully loaded'));
  $this
    ->drupalPost($this
    ->getUrl(), array(), t('Delete'));
  $this
    ->assertResponse(200);
  drupal_static_reset('apachesolr_search_load_all_search_pages');
  $this
    ->drupalGet('admin/config/search/apachesolr/search-pages');
  $this
    ->assertNoText(t('Test Search Page'), t('Search Environment was successfully deleted'));
  apachesolr_environment_save(array(
    'env_id' => 'DummySolr',
    'service_class' => 'DummySolr',
    'name' => 'dummy server',
    'url' => 'http://localhost:8983/solr',
  ));
  $solr = new DummySolr($url = NULL, $env_id = 'DummySolr');
  $params = array(
    'rows' => 5,
  );
  $results = apachesolr_search_run('apachesolr_test', $params, '', '', 0, $solr);
  $query = apachesolr_current_query('DummySolr');
  $this
    ->assertEqual($query
    ->getParam('rows'), 5, 'Passed in rows param overrode default');
}