You are here

public function GoogleCSETestCase::testSiteSearchSettingsConfig in Google Custom Search Engine 7.2

Tests all SiteSearch configuration options.

File

tests/google_cse.test, line 43
Google CSE module tests.

Class

GoogleCSETestCase
@file Google CSE module tests.

Code

public function testSiteSearchSettingsConfig() {

  // Need to have user for this test.
  $this
    ->setupGoogleCSEUser();

  // Need to have Google CSE as default search.
  $this
    ->setupGoogleCSEAsDefaultSearch();

  // Need to setup page with Google CSE search block until redirect issue is fixed.
  // @todo Figure out why going to /search/google ended up in a redirect loop.
  $this
    ->setupGoogleCSESearchPage();

  // Post to config form to save SiteSearch settings.
  $edit = array();
  $edit['google_cse_sitesearch'] = "example.com/user User Search \n example.com/node Node Search";
  $edit['google_cse_sitesearch_form'] = 'radios';
  $this
    ->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));

  // Go to Google CSE search page.
  $this
    ->drupalGet('node/1');

  // Assert that all SiteSearch options are there.
  $this
    ->assertText('Search the web', "Default SiteSearch radio button found.");
  $this
    ->assertText('User Search', "First SiteSearch radio button found.");
  $this
    ->assertText('Node Search', "Second SiteSearch radio button found.");

  // Post different config options for more checks.
  $edit = array();
  $edit['google_cse_sitesearch_form'] = 'select';
  $edit['google_cse_sitesearch_option'] = 'Search Your Site';
  $edit['google_cse_sitesearch_default'] = 1;
  $edit['google_cse_sitesearch'] = "example.com/user \n example.com/node";
  $this
    ->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));

  // Go to Google CSE search page.
  $this
    ->drupalGet('node/1');

  // Assert select options have changed.
  // Need to use raw option since the select list options are not visible.
  $this
    ->assertRaw('<option value="">Search Your Site</option>', "Default SiteSearch select option found.");
  $this
    ->assertRaw('<option value="example.com/user" selected="selected">Search &quot;example.com/user&quot;</option>', "First SiteSearch select option found and selected.");
  $this
    ->assertRaw('<option value="example.com/node">Search &quot;example.com/node&quot;</option>', "Second SiteSearch select option found.");
}