summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-16 23:57:33 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-16 23:57:33 +0000
commit574a2e47eea1bc8e2ea13240e407a32e4b728560 (patch)
tree7c124110e7e71df958fff50b2fb8e0832dd18204 /modules/comment
parent18d22419f3da39ca4bf92f46d605a25957f311be (diff)
downloadbrdo-574a2e47eea1bc8e2ea13240e407a32e4b728560.tar.gz
brdo-574a2e47eea1bc8e2ea13240e407a32e4b728560.tar.bz2
- Patch #345866 by alexanderpas, justinrandell, Dave Reid: remove from hook_block().
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.module64
-rw-r--r--modules/comment/comment.test30
2 files changed, 66 insertions, 28 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index eb088a95e..e3e4d5243 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -261,39 +261,47 @@ function comment_perm() {
}
/**
- * Implementation of hook_block().
- *
- * Generates a block with the most recent comments.
+ * Implementation of hook_block_list().
*/
-function comment_block($op = 'list', $delta = '', $edit = array()) {
- switch ($op) {
- case 'list':
- $blocks['recent']['info'] = t('Recent comments');
-
- return $blocks;
-
- case 'configure':
- $form['comment_block_count'] = array(
- '#type' => 'select',
- '#title' => t('Number of recent comments'),
- '#default_value' => variable_get('comment_block_count', 10),
- '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
- '#description' => t('Number of comments displayed in the <em>Recent comments</em> block.'),
- );
+function comment_block_list() {
+ $blocks['recent']['info'] = t('Recent comments');
- return $form;
+ return $blocks;
+}
- case 'save':
- variable_set('comment_block_count', (int)$edit['comment_block_count']);
- break;
+/**
+ * Implementation of hook_block_configure().
+ */
+function comment_block_configure($delta = '') {
+ $form['comment_block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent comments'),
+ '#default_value' => variable_get('comment_block_count', 10),
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ '#description' => t('Number of comments displayed in the <em>Recent comments</em> block.'),
+ );
- case 'view':
- if (user_access('access comments')) {
- $block['subject'] = t('Recent comments');
- $block['content'] = theme('comment_block');
+ return $form;
+}
- return $block;
- }
+/**
+ * Implementation of hook_block_save().
+ */
+function comment_block_save($delta = '', $edit = array()) {
+ variable_set('comment_block_count', (int)$edit['comment_block_count']);
+}
+
+/**
+ * Implementation of hook_block_view().
+ *
+ * Generates a block with the most recent comments.
+ */
+function comment_block_view($delta = '') {
+ if (user_access('access comments')) {
+ $block['subject'] = t('Recent comments');
+ $block['content'] = theme('comment_block');
+
+ return $block;
}
}
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index 7bc70072e..2de972d03 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -546,3 +546,33 @@ class CommentApprovalTest extends CommentHelperCase {
$this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
}
}
+
+class CommentBlockTestCase extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Block availability'),
+ 'description' => t('Check if the recent comments block is available.'),
+ 'group' => t('Comment'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('comment');
+
+ // Create and login user
+ $admin_user = $this->drupalCreateUser(array('administer blocks'));
+ $this->drupalLogin($admin_user);
+ }
+
+ function testRecentCommentBlock() {
+ // Set block title to confirm that the interface is availble.
+ $this->drupalPost('admin/build/block/configure/comment/recent', 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['comment_recent[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.'));
+ }
+}