You are here

function DrupalSolrOfflineEnvironmentWebTestCase::testServerOffline in Apache Solr Search 6.3

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

Asserts that the module was installed and that a notice appears that the server is offline

File

tests/apachesolr_base.test, line 90
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 testServerOffline() {

  // Load the default server and reset the static
  $env_id = apachesolr_default_environment(NULL, TRUE);
  $environment = apachesolr_environment_load($env_id, TRUE);
  $environment['url'] = 'http://localhost/solr/core_that_should_not_exist';
  apachesolr_environment_save($environment);
  cache_clear_all('apachesolr:environments', 'cache_apachesolr');
  $status = apachesolr_server_status($environment['url']);
  $this
    ->assertFalse($status, t('A false URL could not be loaded and is offline'));
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('admin/settings/apachesolr');
  $text = t('The server seems to be unavailable. Please verify the server settings');
  $this
    ->assertText($text, t('When checking the status of the server it gives the correct message to inform the user that the server is not reachable'));
}