public function GoogleApplianceResultsPageSearchForm::testCase in Google Search Appliance 7
File
- testing/
google_appliance.test, line 475 - Implements automated simpletest routines for integration testing of the Google Appliance module.
Class
- GoogleApplianceResultsPageSearchForm
- Results page search form: test that we get a blank page with the results page search form, and any possible errors are hidden, then test that submitting a search redirects back to the same page with terms in the form. Also tests effects of Page…
Code
public function testCase() {
// go to settings and change the results page title
$settings = array(
'hostname' => 'http://www.mygsa.net',
'collection' => 'default_collection',
'frontend' => 'default_frontend',
'timeout' => 10,
'autofilter' => '1',
'query_inspection' => FALSE,
'search_title' => $this
->randomName(16),
'results_per_page' => 16,
);
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
// look for success message
$this
->assertText(t('The configuration options have been saved'), t('Successful module settings save (changed the search title).'));
// go to the results page
$this
->drupalGet('gsearch');
$this
->assertResponse(200, t('<b>{MTP:2.3.3.5}</b> Successfully went to the results page without a query (successful interaction: pre-search form state).'));
// we should have the form
$this
->assertFieldById('edit-search-keys', '', t('<b>{MTP:2.3.3.6}</b> Found the results page search form with empty field (expected behavior: pre-query search form state).'));
// we should have the prompt
$this
->assertText(t('Enter the terms you wish to search for.'), t('<b>{MTP:2.2.6.7}</b> Search prompt found on pre-serach state of results page (expected behavior).'));
// we should not have any results text ... no results error messages begin
// with the 'Search Results' heading
$this
->assertNoText(t('Search Results'), t('<b>{MTP:2.3.3.8}</b> Pre-search page state does not include results messages (expected behavior).'));
// submit the search form
$terms = array(
'search_keys' => $this
->randomName(8),
);
$this
->drupalPost('gsearch', $terms, t('Search'));
// confirm that the user is redirected to the results page
$this
->assertEqual($this
->getUrl(), url('gsearch/' . $terms['search_keys'], array(
'absolute' => TRUE,
)), t('<b>{MTP:2.3.3.9}</b> Results Page Search Form sumbission redirected to correct url (successful interaction).'));
// check that we have the search query in the search keys field
$this
->assertFieldByName('search_keys', $terms['search_keys'], t('<b>{MTP:2.3.3.10}</b> Found the results page search form with the search query in the search keys field (successful interaction).'));
// ensure that we now have "No Results" text.
$this
->assertText(t('No Results'), t('Post-search page state includes results messages (successful interaction).'));
}