You are here

function DrupalSolrOfflineEnvironmentWebTestCase::testCreateNewSearchEnvironment in Apache Solr Search 7

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

Asserts that we can edit a search environment

File

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

Class

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

Code

function testCreateNewSearchEnvironment() {

  // Create a new environment
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('admin/config/search/apachesolr/settings');
  $this
    ->assertText(t('Add search environment'), t('Create new environment link is available'));
  $this
    ->clickLink(t('Add search environment'));
  $this
    ->assertText(t('Make this Solr search environment the default'), t('Environment creation page successfully added'));
  $edit = array(
    'url' => 'http://localhost:8983/solr',
    'name' => 'my test description',
    'env_id' => 'solr_test',
  );
  $this
    ->drupalPost($this
    ->getUrl(), $edit, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('admin/config/search/apachesolr/settings');
  $this
    ->assertText(t('my test description'), t('Search Environment was successfully created'));

  // Make this new search environment the default
  $this
    ->drupalGet('admin/config/search/apachesolr/settings');

  // Click on the second environment edit link
  $this
    ->clickLink(t('Edit'), 1);
  $this
    ->assertText(t('Example: http://localhost:8983/solr'), t('Edit page was successfully loaded'));
  $edit = array(
    'make_default' => 1,
    'conf[apachesolr_read_only]' => APACHESOLR_READ_ONLY,
  );
  $this
    ->drupalPost($this
    ->getUrl(), $edit, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('admin/config/search/apachesolr/settings');
  $this
    ->assertText(t('my test description (Default)'), t('New Search environment was successfully changed to default environment'));

  // Clear our cache.
  apachesolr_environments_clear_cache();
  $mode = apachesolr_environment_variable_get('solr_test', 'apachesolr_read_only', APACHESOLR_READ_WRITE);
  $this
    ->assertEqual($mode, APACHESOLR_READ_ONLY, 'Environment successfully changed to read only');
}