class DrupalSolrOfflineSearchPagesWebTestCase in Apache Solr Search 8
Same name and namespace in other branches
- 6.3 tests/apachesolr_base.test \DrupalSolrOfflineSearchPagesWebTestCase
- 7 tests/apachesolr_base.test \DrupalSolrOfflineSearchPagesWebTestCase
@file Unit test class that provides tests for base functionality of the Apachesolr Module without having the need of a Solr Server
Hierarchy
- class \DrupalSolrOfflineWebTestCase extends \DrupalWebTestCase
Expanded class hierarchy of DrupalSolrOfflineSearchPagesWebTestCase
File
- tests/
apachesolr_base.test, line 238 - Unit test class that provides tests for base functionality of the Apachesolr Module without having the need of a Solr Server
View source
class DrupalSolrOfflineSearchPagesWebTestCase extends DrupalSolrOfflineWebTestCase {
/**
* A global basic user who can search.
*/
var $basic_user;
/**
* A global administrative user who can administer search.
*/
var $admin_user;
public static function getInfo() {
return array(
'name' => 'Solr Search Pages',
'description' => 'Tests search pages functionality of the Solr module',
'group' => 'ApacheSolr',
);
}
/**
* Implementation of setUp().
*/
function setUp() {
parent::setUp('apachesolr', 'apachesolr_search', 'search', 'apachesolr_test');
// Create a basic user, which is subject to moderation.
$permissions = array(
'access content',
'search content',
);
$basic_user = $this
->drupalCreateUser($permissions);
// Create an admin user that can bypass revision moderation.
$permissions = array(
'access content',
'search content',
'administer nodes',
'administer search',
);
$admin_user = $this
->drupalCreateUser($permissions);
// Assign users to their test suite-wide properties.
$this->basic_user = $basic_user;
$this->admin_user = $admin_user;
// Make sure our environment does not exists
$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);
// Reset all caches
apachesolr_load_all_environments(TRUE);
}
/**
* Asserts that we can edit a search environment
*/
function testCheckCoreSearchPage() {
// Create a new environment
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/config/search/apachesolr/search-pages');
$this
->assertText(t('Core Search'), t('Core Search page is available'));
}
/**
* Asserts that we can edit a search environment
*/
function testEditSearchPage() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/config/search/apachesolr/search-pages');
$this
->clickLink(t('Edit'));
$this
->assertText(t('The human-readable name of the search page configuration'), t('Edit page was succesfully loaded'));
$edit = array(
'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 succesfully edited'));
$this
->assertText('search/searchdifferentpath', t('Search path was updated'));
$this
->drupalGet('search/searchdifferentpath');
$this
->assertText(t('Search is temporarily unavailable. If the problem persists, please contact the site administrator.'), t('Search path was successfully created and is accessible'));
}
/**
* Asserts that we can clone a search page
*/
function testCloneSearchPage() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/config/search/apachesolr/search-pages');
$this
->assertText(t('Clone'), t('Clone button is available'));
$this
->drupalGet('admin/config/search/apachesolr/search-pages/core_search/clone');
$this
->assertText(t('Are you sure you want to clone search page Core Search?'), t('Clone confirmation page was succesfully loaded'));
$this
->drupalPost($this
->getUrl(), array(), t('Clone'));
$this
->assertResponse(200);
drupal_static_reset('apachesolr_search_load_all_search_pages');
$this
->drupalGet('admin/config/search/apachesolr/search-pages');
$this
->assertText(t('Core Search [cloned]'), 'Search page was succesfully cloned');
}
/**
* Asserts that we can edit a search environment
*/
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 succesfully 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 succesfully 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 succesfully 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 succesfully 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');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalSolrOfflineSearchPagesWebTestCase:: |
property | A global administrative user who can administer search. | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
property | A global basic user who can search. | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
public static | function | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
function | Implementation of setUp(). | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
function | Asserts that we can edit a search environment | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
function | Asserts that we can clone a search page | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
function | Asserts that we can edit a search environment | ||
DrupalSolrOfflineSearchPagesWebTestCase:: |
function | Asserts that we can edit a search environment | ||
DrupalSolrOfflineWebTestCase:: |
function |