public function GoogleApplianceRelatedSearchesBlock::testCase in Google Search Appliance 7
File
- testing/
google_appliance.test, line 838 - Implements automated simpletest routines for integration testing of the Google Appliance module.
Class
- GoogleApplianceRelatedSearchesBlock
- Block related searches: test that the block is available and displays as expected.
Code
public function testCase() {
// set block title to confirm that the interface is available.
$block_title = $this
->randomName(16);
$this
->drupalPost('admin/structure/block/manage/google_appliance/ga_related_searches/configure', array(
'title' => $block_title,
), t('Save block'));
// confirm block settings update
$this
->assertText(t('The block configuration has been saved.'), t('<b>{MTP:2.3.6.5}</b> Block title set (successful interaction).'));
// Set the block to a region to confirm block is available.
$edit = array();
$edit['blocks[google_appliance_ga_related_searches][region]'] = 'content';
$this
->drupalPost('admin/structure/block', $edit, t('Save blocks'));
$this
->assertText(t('The block settings have been updated.'), t('<b>{MTP:2.3.6.6}</b> Block successfully moved to footer region (successful interaction).'));
// configure the module to connect
$testing_dir = drupal_get_path('module', 'google_appliance') . '/testing';
$settings_fn = $testing_dir . '/test-settings.inc';
$example_settings_fn = $testing_dir . '/test-settings.example.inc';
if (file_exists($settings_fn)) {
// grab the $file_spec array to config the module's connection settings
include_once $settings_fn;
// use those settings
$settings = array(
// define good settings
'hostname' => $file_spec['hostname'],
'collection' => $file_spec['collection'],
'frontend' => $file_spec['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'));
$this
->assertText(t('The configuration options have been saved'), t('Successful module settings save .'));
// submit the search specified in $file_spec via URL (form submission already tested)
$this
->drupalGet('gsearch/' . $file_spec['query']);
// make sure we get a response, and that it is not an error message
$this
->assertResponse(200);
$this
->assertNoText(t('No Results'), t('Search via URL succeeded, and produced a results listing.'));
// ensure that the block shows up
$this
->assertText(t('@block_title', array(
'@block_title' => $block_title,
)), t('<b>{MTP:2.3.6.7}</b> Found block title for related search block on the page (expected behavior)'));
// no real good way to identify the label of a related search link, so whether or not
// clicking those links produce a new results page with the expected query (they do) is
// left to manual testing
}
else {
$this
->error('Test settings file not found, aborting test. See ' . $example_settings_fn . ' for more information.');
}
}