Révision 6ff32cea
Ajouté par Florent Torregrosa il y a environ 9 ans
drupal7/modules/comment/comment.test | ||
---|---|---|
13 | 13 |
function setUp() { |
14 | 14 |
parent::setUp('comment', 'search'); |
15 | 15 |
// Create users and test node. |
16 |
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks')); |
|
16 |
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks', 'administer actions'));
|
|
17 | 17 |
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments')); |
18 | 18 |
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid)); |
19 | 19 |
} |
... | ... | |
1973 | 1973 |
$this->clearWatchdog(); |
1974 | 1974 |
} |
1975 | 1975 |
|
1976 |
/** |
|
1977 |
* Tests the unpublish comment by keyword action. |
|
1978 |
*/ |
|
1979 |
public function testCommentUnpublishByKeyword() { |
|
1980 |
$this->drupalLogin($this->admin_user); |
|
1981 |
$callback = 'comment_unpublish_by_keyword_action'; |
|
1982 |
$hash = drupal_hash_base64($callback); |
|
1983 |
$comment_text = $keywords = $this->randomName(); |
|
1984 |
$edit = array( |
|
1985 |
'actions_label' => $callback, |
|
1986 |
'keywords' => $keywords, |
|
1987 |
); |
|
1988 |
|
|
1989 |
$this->drupalPost("admin/config/system/actions/configure/$hash", $edit, t('Save')); |
|
1990 |
|
|
1991 |
$action = db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE callback = :callback", array(':callback' => $callback))->fetchObject(); |
|
1992 |
|
|
1993 |
$this->assertTrue($action, 'The action could be loaded.'); |
|
1994 |
|
|
1995 |
$comment = $this->postComment($this->node, $comment_text, $this->randomName()); |
|
1996 |
|
|
1997 |
// Load the full comment so that status is available. |
|
1998 |
$comment = comment_load($comment->id); |
|
1999 |
|
|
2000 |
$this->assertTrue($comment->status == COMMENT_PUBLISHED, 'The comment status was set to published.'); |
|
2001 |
|
|
2002 |
comment_unpublish_by_keyword_action($comment, array('keywords' => array($keywords))); |
|
2003 |
|
|
2004 |
// We need to make sure that the comment has been saved with status |
|
2005 |
// unpublished. |
|
2006 |
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_NOT_PUBLISHED, 'Comment was unpublished.'); |
|
2007 |
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $comment->subject), 'Found watchdog message.'); |
|
2008 |
$this->clearWatchdog(); |
|
2009 |
} |
|
2010 |
|
|
1976 | 2011 |
/** |
1977 | 2012 |
* Verify that a watchdog message has been entered. |
1978 | 2013 |
* |
Formats disponibles : Unified diff
Update core to 7.36