public function GoogleApplianceSettingsValidateTimeout::testCase in Google Search Appliance 7
File
- testing/
google_appliance.test, line 100 - Implements automated simpletest routines for integration testing of the Google Appliance module.
Class
- GoogleApplianceSettingsValidateTimeout
- test the timeout settings validator
Code
public function testCase() {
$settings = array(
'hostname' => 'http://www.mygooglebox.net',
'collection' => 'default_collection',
'frontend' => 'default_frontend',
'timeout' => '55kdsjeumnd90',
// bad
'autofilter' => '1',
'query_inspection' => FALSE,
'search_title' => $this
->randomName(),
'results_per_page' => 16,
);
// non-numeric
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
// ensure that we see the error message
$this
->assertText(t('Search Timeout should be an integer from'), t('<b>{MTP:2.2.2.5}</b> Found error message for invalid-format timeout (successful catch: non-numeric input).'));
// ensure that we don't have the success message
$this
->assertNoText(t('The configuration options have been saved'), t('Successful save message not found (intended fail).'));
// below lower boundary
$settings['timeout'] = 2;
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
// ensure that we see the error message
$this
->assertText(t('Search Timeout should be an integer from'), t('<b>{MTP:2.2.2.6}</b> Found error message for out of range timeout (successful catch: below lower boundary).'));
// ensure that we don't have the success message
$this
->assertNoText(t('The configuration options have been saved'), t('Successful save message not found (intended fail).'));
// above upper boundary
$settings['timeout'] = 31;
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
$this
->assertText(t('Search Timeout should be an integer from'), t('<b>{MTP:2.2.2.7}</b> Found error message for out of range timeout (successful catch: above upper boundary).'));
// ensure that we don't have the success message
$this
->assertNoText(t('The configuration options have been saved'), t('Successful save message not found (intended fail).'));
// at lower boundary
$settings['timeout'] = 3;
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved'), t('<b>{MTP:2.2.2.8}</b> Successful save message found for timeout at lower boundary (successful pass).'));
// at upper boundary
$settings['timeout'] = 30;
$this
->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));
$this
->assertText(t('The configuration options have been saved'), t('<b>{MTP:2.2.2.9}</b> Successful save message found for timeout at upper boundary (successful pass).'));
}