You are here

public function GoogleApplianceSettingsValidateResultsPerPage::testCase in Google Search Appliance 7

File

testing/google_appliance.test, line 217
Implements automated simpletest routines for integration testing of the Google Appliance module.

Class

GoogleApplianceSettingsValidateResultsPerPage
test results per page settings validator

Code

public function testCase() {
  $settings = array(
    'hostname' => 'http://www.mygooglebox.net',
    'collection' => 'default_collection',
    'frontend' => 'default_frontend',
    'timeout' => 10,
    'autofilter' => '1',
    'query_inspection' => FALSE,
    'search_title' => $this
      ->randomName(),
    'results_per_page' => 'dfsjef',
  );

  // non-numeric
  $this
    ->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));

  // ensure that we see the error message
  $this
    ->assertText(t('Results per page should be an integer from'), t('<b>{MTP:2.3.1.5}</b> Found error message invalid-format in results per page (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 minimum
  $settings['results_per_page'] = 0;
  $this
    ->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));

  // ensure we see the error message
  $this
    ->assertText(t('Results per page should be an integer from'), t('<b>{MTP:2.3.1.6}</b> Found error message for out of range results per page (successful catch: below minimum).'));

  // ensure we don't see the success message
  $this
    ->assertNoText(t('The configuration options have been saved'), t('Successful save message not found (successful catch).'));

  // above maximum
  $settings['results_per_page'] = 1001;
  $this
    ->drupalPost('admin/config/search/google_appliance/settings', $settings, t('Save configuration'));

  // ensure we see the error message
  $this
    ->assertText(t('Results per page should be an integer from'), t('<b>{MTP:2.3.1.7}</b> Found error message for out of range results per page (successful catch: above maximum).'));

  // 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 upper boundary
  $settings['results_per_page'] = 1000;
  $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.3.1.8}</b> Successful save message found for results per page at upper boundary (successful pass).'));

  // at lower boundary
  $settings['results_per_page'] = 1;
  $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.3.1.8}</b> Successful save message found for results per page at lower boundary (successful pass).'));
}