summaryrefslogtreecommitdiff
path: root/modules/search
diff options
context:
space:
mode:
Diffstat (limited to 'modules/search')
-rw-r--r--modules/search/search.module22
-rw-r--r--modules/search/search.test30
2 files changed, 43 insertions, 9 deletions
diff --git a/modules/search/search.module b/modules/search/search.module
index 8bb5a74d3..8c3f496ca 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -158,16 +158,20 @@ function search_perm() {
}
/**
- * Implementation of hook_block().
+ * Implementation of hook_block_list().
*/
-function search_block($op = 'list', $delta = '') {
- if ($op == 'list') {
- $blocks['form']['info'] = t('Search form');
- // Not worth caching.
- $blocks['form']['cache'] = BLOCK_NO_CACHE;
- return $blocks;
- }
- elseif ($op == 'view' && user_access('search content')) {
+function search_block_list() {
+ $blocks['form']['info'] = t('Search form');
+ // Not worth caching.
+ $blocks['form']['cache'] = BLOCK_NO_CACHE;
+ return $blocks;
+}
+
+/**
+ * Implementation of hook_block_view().
+ */
+function search_block_view($delta = '') {
+ if (user_access('search content')) {
$block['content'] = drupal_get_form('search_block_form');
$block['subject'] = t('Search');
return $block;
diff --git a/modules/search/search.test b/modules/search/search.test
index a99d1e00d..c7f9ecc77 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -333,3 +333,33 @@ class SearchRankingTestCase extends DrupalWebTestCase {
}
}
}
+
+class SearchBlockTestCase extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Block availability'),
+ 'description' => t('Check if the search form block is available.'),
+ 'group' => t('Search'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('search');
+
+ // Create and login user
+ $admin_user = $this->drupalCreateUser(array('administer blocks'));
+ $this->drupalLogin($admin_user);
+ }
+
+ function testSearchFormBlock() {
+ // Set block title to confirm that the interface is availble.
+ $this->drupalPost('admin/build/block/configure/search/form', array('title' => $this->randomName(8)), t('Save block'));
+ $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
+
+ // Set the block to a region to confirm block is availble.
+ $edit = array();
+ $edit['search_form[region]'] = 'footer';
+ $this->drupalPost('admin/build/block', $edit, t('Save blocks'));
+ $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
+ }
+}