You are here

public function AcquiaSearchWebTestCase::testEnvironment in Acquia Search 6.3

Tests Acquia Search environment creation.

Tests executed:

  • Acquia Search environment is saved and loaded.
  • Acquia Search environment is set as the default environment when created.
  • The service class is set to AcquiaSearchService.
  • The environment's URL is built as expected.

File

tests/acquia_search.test, line 184

Class

AcquiaSearchWebTestCase
Tests the functionality of the Acquia Search module.

Code

public function testEnvironment() {

  // Enable the Acquia Search environment
  $this
    ->enableEnvironment();

  // Clear the static caches
  $this
    ->clearStaticCache();

  // Load the newly enabled environment
  $environment = apachesolr_environment_load(ACQUIA_SEARCH_ENVIRONMENT_ID);

  // Load the default environment variable
  $default_environment = apachesolr_default_environment();

  // Test all the things!
  // Check if the environment is a valid variable
  $this
    ->assertTrue($environment, t('Acquia Search environment saved.'), 'Acquia Search');

  // Check if the default environment is Acquia Search
  $this
    ->assertEqual(ACQUIA_SEARCH_ENVIRONMENT_ID, $default_environment, t('Acquia Search is set to the default environment.'), 'Acquia Search');

  // Check if the service class is actually the Acquia Search Service Class
  $class = isset($environment['service_class']) ? $environment['service_class'] : '';
  $this
    ->assertEqual('AcquiaSearchService', $class, t('Acquia Search is using the AcquiaSearchService service class.'), 'Acquia Search');

  // Check if the url is the same as the one we wanted to save.
  $this
    ->assertEqual($this->url, $environment['url'], t('Acquia Search is connected to the expected URL.'), 'Acquia Search');
}