- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
<?php
// $Id$
2008-09-08 21:37:21 +00:00
class CommentHelperCase extends DrupalWebTestCase {
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
protected $admin_user;
protected $web_user;
protected $node;
function setUp() {
2009-06-03 06:52:29 +00:00
parent::setUp('comment', 'search');
2009-10-08 08:16:54 +00:00
// Create users and test node.
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks'));
2010-01-03 22:30:26 +00:00
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments'));
2009-10-08 08:16:54 +00:00
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
}
2008-09-08 21:37:21 +00:00
/**
* Post comment.
*
2009-12-13 09:14:21 +00:00
* @param $node
* Node to post comment on.
* @param $comment
* Comment body.
* @param $subject
* Comment subject.
* @param $contact
* Set to NULL for no contact info, TRUE to ignore success checking, and
* array of values to set contact info.
2008-09-08 21:37:21 +00:00
*/
2009-12-13 09:14:21 +00:00
function postComment($node, $comment, $subject = '', $contact = NULL) {
2010-01-07 05:23:52 +00:00
$langcode = LANGUAGE_NONE;
2008-09-08 21:37:21 +00:00
$edit = array();
2010-01-07 05:23:52 +00:00
$edit['comment_body[' . $langcode . '][0][value]'] = $comment;
2008-09-08 21:37:21 +00:00
2009-10-16 13:20:16 +00:00
$preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL);
$subject_mode = variable_get('comment_subject_field_article', 1);
2008-09-08 21:37:21 +00:00
2009-10-16 13:20:16 +00:00
// Must get the page before we test for fields.
2008-09-08 21:37:21 +00:00
if ($node !== NULL) {
$this->drupalGet('comment/reply/' . $node->nid);
}
2009-10-16 13:20:16 +00:00
if ($subject_mode == TRUE) {
$edit['subject'] = $subject;
}
else {
$this->assertNoFieldByName('subject', '', t('Subject field not found.'));
}
if ($contact !== NULL && is_array($contact)) {
$edit += $contact;
}
switch ($preview_mode) {
case DRUPAL_REQUIRED:
// Preview required so no save button should be found.
$this->assertNoFieldByName('op', t('Save'), t('Save button not found.'));
$this->drupalPost(NULL, $edit, t('Preview'));
// Don't break here so that we can test post-preview field presence and
// function below.
case DRUPAL_OPTIONAL:
$this->assertFieldByName('op', t('Preview'), t('Preview button found.'));
$this->assertFieldByName('op', t('Save'), t('Save button found.'));
$this->drupalPost(NULL, $edit, t('Save'));
break;
case DRUPAL_DISABLED:
$this->assertNoFieldByName('op', t('Preview'), t('Preview button not found.'));
$this->assertFieldByName('op', t('Save'), t('Save button found.'));
$this->drupalPost(NULL, $edit, t('Save'));
break;
2008-09-08 21:37:21 +00:00
}
$match = array();
// Get comment ID
2009-09-22 07:36:57 +00:00
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
2008-09-08 21:37:21 +00:00
// Get comment.
if ($contact !== TRUE) { // If true then attempting to find error message.
2009-02-07 20:10:40 +00:00
if ($subject) {
$this->assertText($subject, 'Comment subject posted.');
}
2008-09-19 03:11:53 +00:00
$this->assertText($comment, 'Comment body posted.');
2008-09-08 21:37:21 +00:00
$this->assertTrue((!empty($match) && !empty($match[1])), t('Comment id found.'));
}
if (isset($match[1])) {
return (object) array('id' => $match[1], 'subject' => $subject, 'comment' => $comment);
}
}
/**
* Checks current page for specified comment.
*
* @param object $comment Comment object.
* @param boolean $reply The comment is a reply to another comment.
* @return boolean Comment found.
*/
function commentExists($comment, $reply = FALSE) {
if ($comment && is_object($comment)) {
$regex = '/' . ($reply ? '<div class="indented">(.*?)' : '');
$regex .= '<a id="comment-' . $comment->id . '"(.*?)'; // Comment anchor.
$regex .= '<div(.*?)'; // Begin in comment div.
$regex .= $comment->subject . '(.*?)'; // Match subject.
$regex .= $comment->comment . '(.*?)'; // Match comment.
2009-07-28 10:09:25 +00:00
$regex .= '/s';
2008-09-08 21:37:21 +00:00
return (boolean)preg_match($regex, $this->drupalGetContent());
}
else {
return FALSE;
}
}
/**
* Delete comment.
*
* @param object $comment
* Comment to delete.
*/
function deleteComment($comment) {
2009-10-16 20:40:05 +00:00
$this->drupalPost('comment/' . $comment->id . '/delete', array(), t('Delete'));
2008-09-08 21:37:21 +00:00
$this->assertText(t('The comment and all its replies have been deleted.'), t('Comment deleted.'));
}
/**
* Set comment subject setting.
*
* @param boolean $enabled
* Subject value.
*/
function setCommentSubject($enabled) {
$this->setCommentSettings('comment_subject_field', ($enabled ? '1' : '0'), 'Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.');
}
/**
* Set comment preview setting.
*
2009-10-16 13:20:16 +00:00
* @param int $mode
2008-09-08 21:37:21 +00:00
* Preview value.
*/
2009-10-16 13:20:16 +00:00
function setCommentPreview($mode) {
switch ($mode) {
case DRUPAL_DISABLED:
$mode_text = 'disabled';
break;
case DRUPAL_OPTIONAL:
$mode_text = 'optional';
break;
case DRUPAL_REQUIRED:
$mode_text = 'required';
break;
}
$this->setCommentSettings('comment_preview', $mode, 'Comment preview ' . $mode_text . '.');
2008-09-08 21:37:21 +00:00
}
/**
2009-11-12 07:00:48 +00:00
* Set comment form location setting.
2008-09-08 21:37:21 +00:00
*
* @param boolean $enabled
* Form value.
*/
function setCommentForm($enabled) {
2009-06-19 13:03:53 +00:00
$this->setCommentSettings('comment_form_location', ($enabled ? COMMENT_FORM_BELOW : COMMENT_FORM_SEPARATE_PAGE), 'Comment controls ' . ($enabled ? 'enabled' : 'disabled') . '.');
2008-09-08 21:37:21 +00:00
}
/**
* Set comment anonymous level setting.
*
* @param integer $level
* Anonymous level.
*/
function setCommentAnonymous($level) {
$this->setCommentSettings('comment_anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
}
/**
* Set the default number of comments per page.
*
* @param integer $comments
* Comments per page value.
*/
function setCommentsPerPage($number) {
2009-06-19 13:03:53 +00:00
$this->setCommentSettings('comment_default_per_page', $number, 'Number of comments per page set to ' . $number . '.');
2008-09-08 21:37:21 +00:00
}
/**
* Set comment setting for article content type.
*
* @param string $name
* Name of variable.
* @param string $value
* Value of variable.
* @param string $message
* Status message to display.
*/
function setCommentSettings($name, $value, $message) {
variable_set($name . '_article', $value);
$this->assertTrue(TRUE, t($message)); // Display status message.
}
/**
* Check for contact info.
*
* @return boolean Contact info is available.
*/
function commentContactInfoAvailable() {
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->drupalGetContent());
}
/**
* Perform the specified operation on the specified comment.
*
* @param object $comment
* Comment to perform operation on.
* @param string $operation
* Operation to perform.
* @param boolean $aproval
* Operation is found on approval page.
*/
function performCommentOperation($comment, $operation, $approval = FALSE) {
$edit = array();
$edit['operation'] = $operation;
$edit['comments[' . $comment->id . ']'] = TRUE;
2009-07-30 19:24:21 +00:00
$this->drupalPost('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update'));
2008-09-08 21:37:21 +00:00
if ($operation == 'delete') {
$this->drupalPost(NULL, array(), t('Delete comments'));
2009-07-31 19:44:21 +00:00
$this->assertRaw(t('Deleted @count comments.', array('@count' => 1)), t('Operation "' . $operation . '" was performed on comment.'));
2008-09-08 21:37:21 +00:00
}
else {
$this->assertText(t('The update has been performed.'), t('Operation "' . $operation . '" was performed on comment.'));
}
}
/**
* Get the comment ID for an unapproved comment.
*
* @param string $subject
* Comment subject to find.
* @return integer
* Comment id.
*/
function getUnapprovedComment($subject) {
2009-07-30 19:24:21 +00:00
$this->drupalGet('admin/content/comment/approval');
2008-09-08 21:37:21 +00:00
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->drupalGetContent(), $match);
return $match[2];
}
}
class CommentInterfaceTest extends CommentHelperCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2008-09-08 21:37:21 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Comment interface',
'description' => 'Test comment user interfaces.',
'group' => 'Comment',
2008-09-08 21:37:21 +00:00
);
}
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
/**
* Test comment interface.
*/
function testCommentInterface() {
2010-01-07 05:23:52 +00:00
$langcode = LANGUAGE_NONE;
2009-10-16 13:20:16 +00:00
// Set comments to have subject and preview disabled.
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogin($this->admin_user);
2009-10-16 13:20:16 +00:00
$this->setCommentPreview(DRUPAL_DISABLED);
2009-06-19 13:03:53 +00:00
$this->setCommentForm(TRUE);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->setCommentSubject(FALSE);
2009-07-01 12:06:22 +00:00
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogout();
2009-10-16 13:20:16 +00:00
// Post comment #1 without subject or preview.
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogin($this->web_user);
2009-10-16 13:20:16 +00:00
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Set comments to have subject and preview to required.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->setCommentSubject(TRUE);
2009-10-16 13:20:16 +00:00
$this->setCommentPreview(DRUPAL_REQUIRED);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogout();
2009-10-16 13:20:16 +00:00
// Create comment #2 that allows subject and requires preview.
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogin($this->web_user);
2008-09-19 03:11:53 +00:00
$subject_text = $this->randomName();
$comment_text = $this->randomName();
2009-10-16 13:20:16 +00:00
$comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
2008-10-14 20:34:56 +00:00
$comment_loaded = comment_load($comment->id);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
2008-09-19 03:11:53 +00:00
// Check comment display.
$this->drupalGet('node/' . $this->node->nid . '/' . $comment->id);
$this->assertText($subject_text, t('Individual comment subject found.'));
$this->assertText($comment_text, t('Individual comment body found.'));
2009-10-16 13:20:16 +00:00
// Set comments to have subject and preview to optional.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->drupalLogout();
// Reply to comment #2 creating comment #3 with optional preview and no
// subject though field enabled.
$this->drupalLogin($this->web_user);
2008-05-30 07:30:53 +00:00
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
2008-09-19 03:11:53 +00:00
$this->assertText($subject_text, t('Individual comment-reply subject found.'));
$this->assertText($comment_text, t('Individual comment-reply body found.'));
2009-10-16 13:20:16 +00:00
$reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
2008-10-14 20:34:56 +00:00
$reply_loaded = comment_load($reply->id);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($reply, TRUE), t('Reply found.'));
2008-10-14 20:34:56 +00:00
$this->assertEqual($comment->id, $reply_loaded->pid, t('Pid of a reply to a comment is set correctly.'));
2009-05-24 17:39:35 +00:00
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.00/', $reply_loaded->thread, t('Thread of reply grows correctly.'));
2008-10-14 20:34:56 +00:00
2009-10-16 13:20:16 +00:00
// Second reply to comment #3 creating comment #4.
2008-10-14 20:34:56 +00:00
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
$this->assertText($subject_text, t('Individual comment-reply subject found.'));
$this->assertText($comment_text, t('Individual comment-reply body found.'));
2009-07-01 12:06:22 +00:00
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
2008-10-14 20:34:56 +00:00
$reply_loaded = comment_load($reply->id);
$this->assertTrue($this->commentExists($reply, TRUE), t('Second reply found.'));
2009-05-24 17:39:35 +00:00
$this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, t('Thread of second reply grows correctly.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Edit reply.
2009-10-16 20:40:05 +00:00
$this->drupalGet('comment/' . $reply->id . '/edit');
2009-07-01 12:06:22 +00:00
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.'));
2008-06-24 17:01:33 +00:00
2008-06-18 16:06:42 +00:00
// Correct link count
$this->drupalGet('node');
2009-10-16 13:20:16 +00:00
$this->assertRaw('4 comments', t('Link to the 4 comments exist.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
2009-06-19 13:03:53 +00:00
// Confirm a new comment is posted to the correct page.
2008-06-14 16:02:50 +00:00
$this->setCommentsPerPage(2);
2009-07-01 12:06:22 +00:00
$comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
2009-06-19 13:03:53 +00:00
$this->assertTrue($this->commentExists($comment_new_page), t('Page one exists. %s'));
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 1)));
2008-06-14 16:02:50 +00:00
$this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s'));
$this->setCommentsPerPage(50);
2008-09-19 03:00:10 +00:00
// Attempt to post to node with comments disabled.
2009-03-17 12:41:54 +00:00
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_HIDDEN));
2008-09-19 03:00:10 +00:00
$this->assertTrue($this->node, t('Article node created.'));
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('This discussion is closed', t('Posting to node with comments disabled'));
$this->assertNoField('edit-comment', t('Comment body field found.'));
2008-11-11 16:49:38 +00:00
// Attempt to post to node with read-only comments.
2009-03-17 12:41:54 +00:00
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_CLOSED));
2008-09-19 03:00:10 +00:00
$this->assertTrue($this->node, t('Article node created.'));
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('This discussion is closed', t('Posting to node with comments read-only'));
$this->assertNoField('edit-comment', t('Comment body field found.'));
// Attempt to post to node with comments enabled (check field names etc).
2009-03-17 12:41:54 +00:00
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN));
2008-09-19 03:00:10 +00:00
$this->assertTrue($this->node, t('Article node created.'));
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertNoText('This discussion is closed', t('Posting to node with comments enabled'));
2010-01-07 05:23:52 +00:00
$this->assertField('edit-comment-body-' . $langcode . '-0-value', t('Comment body field found.'));
2008-09-19 03:00:10 +00:00
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->deleteComment($comment);
2008-06-14 16:02:50 +00:00
$this->deleteComment($comment_new_page);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
2008-05-30 07:30:53 +00:00
$this->drupalGet('node/' . $this->node->nid);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertFalse($this->commentExists($comment), t('Comment not found.'));
$this->assertFalse($this->commentExists($reply, TRUE), t('Reply not found.'));
2008-09-08 21:37:21 +00:00
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Enabled comment form on node page.
$this->drupalLogin($this->admin_user);
$this->setCommentForm(TRUE);
$this->drupalLogout();
// Submit comment through node form.
$this->drupalLogin($this->web_user);
2008-05-30 07:30:53 +00:00
$this->drupalGet('node/' . $this->node->nid);
2009-07-01 12:06:22 +00:00
$form_comment = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($form_comment), t('Form comment found.'));
// Disable comment form on node page.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$this->setCommentForm(FALSE);
}
2008-09-08 21:37:21 +00:00
}
2009-08-09 00:55:50 +00:00
/**
* Test previewing comments.
*/
class CommentPreviewTest extends CommentHelperCase {
public static function getInfo() {
return array(
'name' => 'Comment preview',
'description' => 'Test comment preview.',
'group' => 'Comment',
);
}
/**
* Test comment preview.
*/
function testCommentPreview() {
2010-01-07 05:23:52 +00:00
$langcode = LANGUAGE_NONE;
2009-08-09 00:55:50 +00:00
// As admin user, configure comment settings.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(TRUE);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$this->drupalLogout();
// As web user, fill in node creation form and preview node.
$this->drupalLogin($this->web_user);
$edit = array();
$edit['subject'] = $this->randomName(8);
2010-01-07 05:23:52 +00:00
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
2009-08-09 00:55:50 +00:00
$this->drupalPost('node/' . $this->node->nid, $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
2010-01-07 05:23:52 +00:00
$this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.'));
2009-08-09 00:55:50 +00:00
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
2010-01-07 05:23:52 +00:00
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
2009-08-09 00:55:50 +00:00
}
2009-10-08 08:16:54 +00:00
2009-08-09 00:55:50 +00:00
/**
* Test comment edit and preview.
*/
function testCommentEditPreview() {
2010-01-07 05:23:52 +00:00
$langcode = LANGUAGE_NONE;
2009-08-09 00:55:50 +00:00
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'post comments without approval'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(TRUE);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
2009-10-08 08:16:54 +00:00
2009-08-09 00:55:50 +00:00
$edit = array();
$edit['subject'] = $this->randomName(8);
2010-01-07 05:23:52 +00:00
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
2009-11-28 09:18:17 +00:00
$edit['name'] = $web_user->name;
2009-08-09 00:55:50 +00:00
$edit['date'] = '2008-03-02 17:23 +0300';
$expected_date = format_date(strtotime($edit['date']));
2010-01-07 05:23:52 +00:00
$comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE);
2009-10-16 20:40:05 +00:00
$this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));
2009-10-08 08:16:54 +00:00
2009-08-09 00:55:50 +00:00
// Check that the preview is displaying the subject, comment, author and date correctly.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
2010-01-07 05:23:52 +00:00
$this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.'));
2009-11-28 09:18:17 +00:00
$this->assertText($edit['name'], t('Author displayed.'));
2009-08-09 00:55:50 +00:00
$this->assertText($expected_date, t('Date displayed.'));
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
2010-01-07 05:23:52 +00:00
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
2009-11-28 09:18:17 +00:00
$this->assertFieldByName('name', $edit['name'], t('Author field displayed.'));
2009-08-09 00:55:50 +00:00
$this->assertFieldByName('date', $edit['date'], t('Date field displayed.'));
}
}
2008-09-08 21:37:21 +00:00
class CommentAnonymous extends CommentHelperCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2008-09-08 21:37:21 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Anonymous comments',
'description' => 'Test anonymous comments.',
'group' => 'Comment',
2008-09-08 21:37:21 +00:00
);
}
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
/**
* Test anonymous comment functionality.
*/
function testAnonymous() {
$this->drupalLogin($this->admin_user);
// Enabled anonymous user comments.
2009-10-08 08:16:54 +00:00
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => TRUE,
'post comments without approval' => TRUE,
));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
$this->drupalLogout();
// Post anonymous comment without contact info.
$anonymous_comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($anonymous_comment1), t('Anonymous comment without contact info found.'));
// Allow contact info.
$this->drupalLogin($this->admin_user);
$this->setCommentAnonymous('1');
2008-11-21 14:48:59 +00:00
// Attempt to edit anonymous comment.
2009-10-16 20:40:05 +00:00
$this->drupalGet('comment/' . $anonymous_comment1->id . '/edit');
2008-11-21 14:48:59 +00:00
$edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogout();
// Post anonymous comment with contact info (optional).
2008-05-30 07:30:53 +00:00
$this->drupalGet('comment/reply/' . $this->node->nid);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
$anonymous_comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.'));
// Require contact info.
$this->drupalLogin($this->admin_user);
$this->setCommentAnonymous('2');
$this->drupalLogout();
// Try to post comment with contact info (required).
2008-05-30 07:30:53 +00:00
$this->drupalGet('comment/reply/' . $this->node->nid);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
2009-10-16 13:20:16 +00:00
$anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertText(t('E-mail field is required.'), t('E-mail required.')); // Name should have 'Anonymous' for value by default.
$this->assertFalse($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) not found.'));
// Post comment with contact info (required).
2009-10-16 13:20:16 +00:00
$anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('mail' => 'tester@simpletest.org'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) found.'));
// Unpublish comment.
$this->drupalLogin($this->admin_user);
$this->performCommentOperation($anonymous_comment3, 'unpublish');
2009-07-30 19:24:21 +00:00
$this->drupalGet('admin/content/comment/approval');
2008-05-30 07:30:53 +00:00
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was unpublished.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Publish comment.
$this->performCommentOperation($anonymous_comment3, 'publish', TRUE);
2009-07-30 19:24:21 +00:00
$this->drupalGet('admin/content/comment');
2008-05-30 07:30:53 +00:00
$this->assertRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was published.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Delete comment.
$this->performCommentOperation($anonymous_comment3, 'delete');
2009-07-30 19:24:21 +00:00
$this->drupalGet('admin/content/comment');
2008-05-30 07:30:53 +00:00
$this->assertNoRaw('comments[' . $anonymous_comment3->id . ']', t('Comment was deleted.'));
2009-10-08 08:16:54 +00:00
$this->drupalLogout();
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
2008-06-03 16:30:20 +00:00
// Reset.
2009-10-08 08:16:54 +00:00
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => FALSE,
'post comments' => FALSE,
'post comments without approval' => FALSE,
));
2008-09-19 03:00:10 +00:00
2008-11-11 16:49:38 +00:00
// Attempt to view comments while disallowed.
2008-09-19 03:00:10 +00:00
// NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->nid);
2009-07-28 10:09:25 +00:00
$this->assertNoPattern('/<div ([^>]*?)id="comments"([^>]*?)>/', t('Comments were not displayed.'));
2008-09-19 03:00:10 +00:00
$this->assertNoLink('Add new comment', t('Link to add comment was found.'));
2008-11-11 16:49:38 +00:00
2008-09-19 03:00:10 +00:00
// Attempt to view node-comment form while disallowed.
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('You are not authorized to view comments', t('Error attempting to post comment.'));
$this->assertNoFieldByName('subject', '', t('Subject field not found.'));
$this->assertNoFieldByName('comment', '', t('Comment field not found.'));
2009-06-20 07:30:17 +00:00
2009-10-08 08:16:54 +00:00
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => FALSE,
'post comments without approval' => FALSE,
));
2009-06-20 07:30:17 +00:00
$this->drupalGet('node/' . $this->node->nid);
2009-07-28 10:09:25 +00:00
$this->assertPattern('/<div ([^>]*?)id="comments"([^>]*?)>/', t('Comments were displayed.'));
2010-01-11 16:25:16 +00:00
$this->assertLink('Log in', 1, t('Link to log in was found.'));
2009-06-20 07:30:17 +00:00
$this->assertLink('register', 1, t('Link to register was found.'));
2008-06-03 16:30:20 +00:00
}
2008-09-08 21:37:21 +00:00
}
2009-06-19 13:03:53 +00:00
/**
* Verify pagination of comments.
*/
class CommentPagerTest extends CommentHelperCase {
public static function getInfo() {
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Comment paging settings',
'description' => 'Test paging of comments and their settings.',
'group' => 'Comment',
2009-06-19 13:03:53 +00:00
);
}
/**
* Confirm comment paging works correctly with flat and threaded comments.
*/
function testCommentPaging() {
$this->drupalLogin($this->admin_user);
// Set comment variables.
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(FALSE);
// Create a node and three comments.
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$comments = array();
2009-10-16 13:20:16 +00:00
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
2009-06-19 13:03:53 +00:00
2009-07-01 12:06:22 +00:00
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
2009-06-19 13:03:53 +00:00
// Set comments to one per page so that we are able to test paging without
// needing to insert large numbers of comments.
$this->setCommentsPerPage(1);
// Check the first page of the node, and confirm the correct comments are
// shown.
$this->drupalGet('node/' . $node->nid);
$this->assertRaw(t('next'), t('Paging links found.'));
$this->assertTrue($this->commentExists($comments[0]), t('Comment 1 appears on page 1.'));
$this->assertFalse($this->commentExists($comments[1]), t('Comment 2 does not appear on page 1.'));
$this->assertFalse($this->commentExists($comments[2]), t('Comment 3 does not appear on page 1.'));
// Check the second page.
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 1)));
2009-06-19 13:03:53 +00:00
$this->assertTrue($this->commentExists($comments[1]), t('Comment 2 appears on page 2.'));
$this->assertFalse($this->commentExists($comments[0]), t('Comment 1 does not appear on page 2.'));
$this->assertFalse($this->commentExists($comments[2]), t('Comment 3 does not appear on page 2.'));
// Check the third page.
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 2)));
2009-06-19 13:03:53 +00:00
$this->assertTrue($this->commentExists($comments[2]), t('Comment 3 appears on page 3.'));
$this->assertFalse($this->commentExists($comments[0]), t('Comment 1 does not appear on page 3.'));
$this->assertFalse($this->commentExists($comments[1]), t('Comment 2 does not appear on page 3.'));
// Post a reply to the oldest comment and test again.
$replies = array();
$oldest_comment = reset($comments);
$this->drupalGet('comment/reply/' . $node->nid . '/' . $oldest_comment->id);
2009-10-16 13:20:16 +00:00
$reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
2009-06-19 13:03:53 +00:00
$this->setCommentsPerPage(2);
// We are still in flat view - the replies should not be on the first page,
// even though they are replies to the oldest comment.
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
2009-06-19 13:03:53 +00:00
$this->assertFalse($this->commentExists($reply, TRUE), t('In flat mode, reply does not appear on page 1.'));
// If we switch to threaded mode, the replies on the oldest comment
// should be bumped to the first page and comment 6 should be bumped
// to the second page.
2009-07-01 12:06:22 +00:00
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
2009-06-19 13:03:53 +00:00
$this->assertTrue($this->commentExists($reply, TRUE), t('In threaded mode, reply appears on page 1.'));
$this->assertFalse($this->commentExists($comments[1]), t('In threaded mode, comment 2 has been bumped off of page 1.'));
// If (# replies > # comments per page) in threaded expanded view,
// the overage should be bumped.
2009-10-16 13:20:16 +00:00
$reply2 = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
2009-09-29 15:31:17 +00:00
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
2009-06-19 13:03:53 +00:00
$this->assertFalse($this->commentExists($reply2, TRUE), t('In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.'));
$this->drupalLogout();
}
2009-12-08 06:33:11 +00:00
/**
* Test comment ordering and threading.
*/
function testCommentOrderingThreading() {
$this->drupalLogin($this->admin_user);
// Set comment variables.
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(FALSE);
// Display all the comments on the same page.
$this->setCommentsPerPage(1000);
// Create a node and three comments.
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$comments = array();
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the second comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[1]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the first comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[0]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the last comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[2]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the second comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[3]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// At this point, the comment tree is:
// - 0
// - 4
// - 1
// - 3
// - 6
// - 2
// - 5
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
$expected_order = array(
0,
1,
2,
3,
4,
5,
6,
);
$this->drupalGet('node/' . $node->nid);
$this->assertCommentOrder($comments, $expected_order);
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
$expected_order = array(
0,
4,
1,
3,
6,
2,
5,
);
$this->drupalGet('node/' . $node->nid);
$this->assertCommentOrder($comments, $expected_order);
}
/**
* Helper function: assert that the comments are displayed in the correct order.
*
* @param $comments
* And array of comments.
* @param $expected_order
* An array of keys from $comments describing the expected order.
*/
function assertCommentOrder(array $comments, array $expected_order) {
$expected_cids = array();
// First, rekey the expected order by cid.
foreach ($expected_order as $key) {
$expected_cids[] = $comments[$key]->id;
}
$comment_anchors = $this->xpath("//a[starts-with(@id,'comment-')]");
$result_order = array();
foreach ($comment_anchors as $anchor) {
$result_order[] = substr($anchor['id'], 8);
}
return $this->assertIdentical($expected_cids, $result_order, t('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order))));
}
2009-12-11 17:09:00 +00:00
/**
* Test comment_new_page_count().
*/
function testCommentNewPageIndicator() {
$this->drupalLogin($this->admin_user);
// Set comment variables.
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(FALSE);
// Set comments to one per page so that we are able to test paging without
// needing to insert large numbers of comments.
$this->setCommentsPerPage(1);
// Create a node and three comments.
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$comments = array();
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the second comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[1]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the first comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[0]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Post a reply to the last comment.
$this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[2]->id);
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// At this point, the comment tree is:
// - 0
// - 4
// - 1
// - 3
// - 2
// - 5
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
$expected_pages = array(
1 => 5, // Page of comment 5
2 => 4, // Page of comment 4
3 => 3, // Page of comment 3
4 => 2, // Page of comment 2
5 => 1, // Page of comment 1
6 => 0, // Page of comment 0
);
$node = node_load($node->nid);
foreach ($expected_pages as $new_replies => $expected_page) {
$returned = comment_new_page_count($node->comment_count, $new_replies, $node);
$returned_page = is_array($returned) ? $returned['page'] : 0;
$this->assertIdentical($expected_page, $returned_page, t('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
}
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
$expected_pages = array(
1 => 5, // Page of comment 5
2 => 1, // Page of comment 4
3 => 1, // Page of comment 4
4 => 1, // Page of comment 4
5 => 1, // Page of comment 4
6 => 0, // Page of comment 0
);
$node = node_load($node->nid);
foreach ($expected_pages as $new_replies => $expected_page) {
$returned = comment_new_page_count($node->comment_count, $new_replies, $node);
$returned_page = is_array($returned) ? $returned['page'] : 0;
$this->assertEqual($expected_page, $returned_page, t('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
}
}
2009-06-19 13:03:53 +00:00
}
2008-09-08 21:37:21 +00:00
class CommentApprovalTest extends CommentHelperCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2008-09-08 21:37:21 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Comment approval',
'description' => 'Test comment approval functionality.',
'group' => 'Comment',
2008-09-08 21:37:21 +00:00
);
}
2008-06-03 16:30:20 +00:00
/**
2009-07-30 19:24:21 +00:00
* Test comment approval functionality through admin/content/comment.
2008-06-03 16:30:20 +00:00
*/
function testApprovalAdminInterface() {
2008-12-30 16:43:20 +00:00
// Set anonymous comments to require approval.
2009-10-08 08:16:54 +00:00
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => TRUE,
'post comments without approval' => FALSE,
));
$this->drupalLogin($this->admin_user);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
$this->drupalLogout();
// Post anonymous comment without contact info.
$subject = $this->randomName();
$body = $this->randomName();
2009-10-16 13:20:16 +00:00
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
2009-01-14 21:48:24 +00:00
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
2008-09-09 00:29:24 +00:00
// Get unapproved comment id.
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->drupalLogin($this->admin_user);
2008-09-09 00:29:24 +00:00
$anonymous_comment4 = $this->getUnapprovedComment($subject);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$anonymous_comment4 = (object) array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body);
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.'));
// Approve comment.
$this->drupalLogin($this->admin_user);
$this->performCommentOperation($anonymous_comment4, 'publish', TRUE);
$this->drupalLogout();
2008-05-30 07:30:53 +00:00
$this->drupalGet('node/' . $this->node->nid);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
2008-06-03 16:30:20 +00:00
}
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
2008-06-03 16:30:20 +00:00
/**
* Test comment approval functionality through node interface.
*/
function testApprovalNodeInterface() {
2008-12-30 16:43:20 +00:00
// Set anonymous comments to require approval.
2009-10-08 08:16:54 +00:00
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => TRUE,
'post comments without approval' => FALSE,
));
$this->drupalLogin($this->admin_user);
2008-06-03 16:30:20 +00:00
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
$this->drupalLogout();
// Post anonymous comment without contact info.
$subject = $this->randomName();
$body = $this->randomName();
2009-10-16 13:20:16 +00:00
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
2009-01-14 21:48:24 +00:00
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
2008-06-03 16:30:20 +00:00
2008-12-30 16:43:20 +00:00
// Get unapproved comment id.
2008-06-03 16:30:20 +00:00
$this->drupalLogin($this->admin_user);
2008-09-09 00:29:24 +00:00
$anonymous_comment4 = $this->getUnapprovedComment($subject);
2008-06-03 16:30:20 +00:00
$anonymous_comment4 = (object) array('id' => $anonymous_comment4, 'subject' => $subject, 'comment' => $body);
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), t('Anonymous comment was not published.'));
// Approve comment.
$this->drupalLogin($this->admin_user);
2009-05-24 17:39:35 +00:00
$this->drupalGet('node/' . $this->node->nid);
2008-06-03 16:30:20 +00:00
$this->clickLink(t('approve'));
$this->drupalLogout();
2009-05-24 17:39:35 +00:00
$this->drupalGet('node/' . $this->node->nid);
2008-06-03 16:30:20 +00:00
$this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
}
}
2008-12-16 23:57:33 +00:00
2009-02-07 20:10:40 +00:00
/**
* Functional tests for the comment module blocks.
*/
class CommentBlockFunctionalTest extends CommentHelperCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2008-12-16 23:57:33 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Comment blocks',
'description' => 'Test comment block functionality.',
'group' => 'Comment',
2008-12-16 23:57:33 +00:00
);
}
2009-02-07 20:10:40 +00:00
/**
* Test the recent comments block.
*/
function testRecentCommentBlock() {
$this->drupalLogin($this->admin_user);
// Set the block to a region to confirm block is available.
$edit = array(
2009-08-03 03:04:34 +00:00
'comment_recent[region]' => 'sidebar_first',
2009-02-07 20:10:40 +00:00
);
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
2009-08-03 03:04:34 +00:00
$this->assertText(t('The block settings have been updated.'), t('Block saved to first sidebar region.'));
2009-02-07 20:10:40 +00:00
// Set block title and variables.
$block = array(
'title' => $this->randomName(),
'comment_block_count' => 2,
);
2009-10-16 23:48:38 +00:00
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
2009-02-07 20:10:40 +00:00
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
// Add some test comments, one without a subject.
$comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
$comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
2009-10-16 13:20:16 +00:00
$comment3 = $this->postComment($this->node, $this->randomName());
2008-12-16 23:57:33 +00:00
2009-02-07 20:10:40 +00:00
// Test that a user without the 'access comments' permission can not see the block.
$this->drupalLogout();
$this->drupalGet('');
$this->assertNoText($block['title'], t('Block was not found.'));
$this->drupalLogin($this->web_user);
$this->drupalGet('');
$this->assertText($block['title'], t('Block was found.'));
// Test the only the 2 latest comments are shown and in the proper order.
$this->assertNoText($comment1->subject, t('Comment not found in block.'));
$this->assertText($comment2->subject, t('Comment found in block.'));
$this->assertText($comment3->comment, t('Comment found in block.'));
$this->assertTrue(strpos($this->drupalGetContent(), $comment3->comment) < strpos($this->drupalGetContent(), $comment2->subject), t('Comments were ordered correctly in block.'));
2009-03-25 16:54:24 +00:00
// Set the number of recent comments to show to 10.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
$block = array(
'comment_block_count' => 10,
);
2009-10-16 23:48:38 +00:00
$this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
2009-03-25 16:54:24 +00:00
$this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
2009-06-19 13:03:53 +00:00
// Post an additional comment.
$comment4 = $this->postComment($this->node, $this->randomName(), $this->randomName());
// Test that all four comments are shown.
2009-03-25 16:54:24 +00:00
$this->assertText($comment1->subject, t('Comment found in block.'));
$this->assertText($comment2->subject, t('Comment found in block.'));
$this->assertText($comment3->comment, t('Comment found in block.'));
2009-06-19 13:03:53 +00:00
$this->assertText($comment4->subject, t('Comment found in block.'));
// Test that links to comments work when comments are across pages.
$this->setCommentsPerPage(1);
$this->drupalGet('');
$this->clickLink($comment1->subject);
$this->assertText($comment1->subject, t('Comment link goes to correct page.'));
$this->drupalGet('');
$this->clickLink($comment2->subject);
$this->assertText($comment2->subject, t('Comment link goes to correct page.'));
$this->clickLink($comment4->subject);
$this->assertText($comment4->subject, t('Comment link goes to correct page.'));
// Check that when viewing a comment page from a link to the comment, that
// rel="canonical" is added to the head of the document.
$this->assertRaw('<link rel="canonical"', t('Canonical URL was found in the HTML head'));
2008-12-16 23:57:33 +00:00
}
2009-02-07 20:10:40 +00:00
}
2008-12-16 23:57:33 +00:00
2009-02-07 20:10:40 +00:00
/**
* Unit tests for comment module integration with RSS feeds.
*/
class CommentRSSUnitTest extends CommentHelperCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2009-02-07 20:10:40 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Comment RSS',
'description' => 'Test comments as part of an RSS feed.',
'group' => 'Comment',
2009-02-07 20:10:40 +00:00
);
}
2008-12-16 23:57:33 +00:00
2009-02-07 20:10:40 +00:00
/**
* Test comments as part of an RSS feed.
*/
function testCommentRSS() {
2009-05-28 08:37:29 +00:00
// Find comment in RSS feed.
2009-02-07 20:10:40 +00:00
$this->drupalLogin($this->web_user);
$comment = $this->postComment($this->node, $this->randomName(), $this->randomName());
$this->drupalGet('rss.xml');
$raw = '<comments>' . url('node/' . $this->node->nid, array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
$this->assertRaw($raw, t('Comments as part of RSS feed.'));
2009-05-28 08:37:29 +00:00
// Hide comments from RSS feed and check presence.
$this->node->comment = COMMENT_NODE_HIDDEN;
node_save($this->node);
$this->drupalGet('rss.xml');
$this->assertNoRaw($raw, t('Hidden comments is not a part of RSS feed.'));
2008-12-16 23:57:33 +00:00
}
}
2009-10-19 18:28:16 +00:00
2009-10-20 17:33:43 +00:00
/**
2009-11-12 07:00:48 +00:00
* Tests RDFa markup for comments.
2009-10-20 17:33:43 +00:00
*/
class CommentRdfaTestCase extends CommentHelperCase {
2009-10-19 18:28:16 +00:00
public static function getInfo() {
return array(
'name' => 'RDFa comment markup',
'description' => 'Test RDFa markup in comments.',
'group' => 'RDF',
);
}
function setUp() {
parent::setUp('comment', 'rdf');
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer permissions', 'administer blocks'));
2009-11-12 07:00:48 +00:00
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'access user profiles'));
2009-10-19 18:28:16 +00:00
2009-11-12 07:00:48 +00:00
// Enables anonymous user comments.
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
'post comments' => TRUE,
'post comments without approval' => TRUE,
));
// Allows anonymous to leave their contact information.
$this->setCommentAnonymous(COMMENT_ANONYMOUS_MAY_CONTACT);
$this->setCommentPreview(DRUPAL_OPTIONAL);
2009-10-19 18:28:16 +00:00
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
2009-11-12 07:00:48 +00:00
// Creates the nodes on which the test comments will be posted.
$this->drupalLogin($this->web_user);
$this->node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$this->node2 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
2009-10-19 18:28:16 +00:00
$this->drupalLogout();
2009-11-12 07:00:48 +00:00
}
2009-12-16 19:53:53 +00:00
/**
* Tests the presence of the RDFa markup for the number of comments.
*/
function testNumberOfCommentsRdfaMarkup() {
// Posts 2 comments as a registered user.
$this->drupalLogin($this->web_user);
$this->postComment($this->node1, $this->randomName(), $this->randomName());
$this->postComment($this->node1, $this->randomName(), $this->randomName());
// Tests number of comments in teaser view.
$this->drupalGet('node');
$comment_count_teaser = $this->xpath("//div[contains(@typeof, 'sioc:Item')]//li[contains(@class, 'comment_comments')]/a[contains(@property, 'sioc:num_replies') and contains(@content, '2')]");
$this->assertTrue(!empty($comment_count_teaser), t('RDFa markup for the number of comments found on teaser view.'));
// Tests number of comments in full node view.
$this->drupalGet('node/' . $this->node1->nid);
$node_url = url('node/' . $this->node1->nid);
$comment_count_teaser = $this->xpath("/html/head/meta[@about='$node_url' and @property='sioc:num_replies' and @content='2']");
$this->assertTrue(!empty($comment_count_teaser), t('RDFa markup for the number of comments found on full node view.'));
}
2009-11-12 07:00:48 +00:00
/**
* Tests the presence of the RDFa markup for the title, date and author and
* homepage on registered users and anonymous comments.
*/
2009-12-16 19:53:53 +00:00
function testCommentRdfaMarkup() {
2009-10-19 18:28:16 +00:00
2009-11-12 07:00:48 +00:00
// Posts comment #1 as a registered user.
2009-10-19 18:28:16 +00:00
$this->drupalLogin($this->web_user);
2009-11-12 07:00:48 +00:00
$comment1_subject = $this->randomName();
$comment1_body = $this->randomName();
$comment1 = $this->postComment($this->node1, $comment1_body, $comment1_subject);
// Tests comment #1 with access to the user profile.
$this->drupalGet('node/' . $this->node1->nid);
$this->_testBasicCommentRdfaMarkup($comment1);
// Tests comment #1 with no access to the user profile (as anonymous user).
$this->drupalLogout();
$this->drupalGet('node/' . $this->node1->nid);
$this->_testBasicCommentRdfaMarkup($comment1);
// Posts comment #2 as anonymous user.
$comment2_subject = $this->randomName();
$comment2_body = $this->randomName();
$anonymous_user = array();
$anonymous_user['name'] = $this->randomName();
$anonymous_user['mail'] = 'tester@simpletest.org';
$anonymous_user['homepage'] = 'http://example.org/';
$comment2 = $this->postComment($this->node2, $comment2_body, $comment2_subject, $anonymous_user);
$this->drupalGet('node/' . $this->node2->nid);
// Tests comment #2 as anonymous user.
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
// Tests the RDFa markup for the homepage (specific to anonymous comments).
2010-02-07 09:11:28 +00:00
$comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[contains(@class, 'username') and @typeof='sioc:User' and @property='foaf:name' and @href='http://example.org/' and contains(@rel, 'foaf:page')]");
2009-11-12 07:00:48 +00:00
$this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.'));
// There should be no about attribute on anonymous comments.
2010-02-07 09:11:28 +00:00
$comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[@about]");
2009-11-12 07:00:48 +00:00
$this->assertTrue(empty($comment_homepage), t('No about attribute is present on anonymous user comment.'));
// Tests comment #2 as logged in user.
$this->drupalLogin($this->web_user);
$this->drupalGet('node/' . $this->node2->nid);
$this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user);
// Tests the RDFa markup for the homepage (specific to anonymous comments).
2010-02-07 09:11:28 +00:00
$comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[contains(@class, 'username') and @typeof='sioc:User' and @property='foaf:name' and @href='http://example.org/' and contains(@rel, 'foaf:page')]");
2009-11-12 07:00:48 +00:00
$this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.'));
// There should be no about attribute on anonymous comments.
2010-02-07 09:11:28 +00:00
$comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[@about]");
2009-11-12 07:00:48 +00:00
$this->assertTrue(empty($comment_homepage), t('No about attribute is present on anonymous user comment.'));
}
2009-10-19 18:28:16 +00:00
2009-11-12 07:00:48 +00:00
/**
2009-12-16 19:53:53 +00:00
* Helper function for testCommentRdfaMarkup().
2009-11-12 07:00:48 +00:00
*
* Tests the current page for basic comment RDFa markup.
*
* @param $comment
* Comment object.
2010-02-07 09:11:28 +00:00
* @param $account
2009-11-12 07:00:48 +00:00
* An array containing information about an anonymous user.
*/
function _testBasicCommentRdfaMarkup($comment, $account = array()) {
2010-02-07 09:11:28 +00:00
$comment_container = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]");
$this->assertTrue(!empty($comment_container), t('Comment RDF type for comment found.'));
$comment_title = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//h3[@property='dc:title']");
$this->assertEqual((string)$comment_title[0]->a, $comment->subject, t('RDFa markup for the comment title found.'));
$comment_date = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//*[contains(@property, 'dc:date') and contains(@property, 'dc:created')]");
$this->assertTrue(!empty($comment_date), t('RDFa markup for the date of the comment found.'));
2009-11-12 07:00:48 +00:00
// The author tag can be either a or span
2010-02-07 09:11:28 +00:00
$comment_author = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/*[contains(@class, 'username') and @typeof='sioc:User' and @property='foaf:name']");
2009-11-12 07:00:48 +00:00
$name = empty($account['name']) ? $this->web_user->name : $account['name'] . ' (not verified)';
2010-02-07 09:11:28 +00:00
$this->assertEqual((string)$comment_author[0], $name, t('RDFa markup for the comment author found.'));
$comment_body = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//div[@class='content']//div[contains(@class, 'comment-body')]//div[@property='content:encoded']");
$this->assertEqual((string)$comment_body[0]->p, $comment->comment, t('RDFa markup for the comment body found.'));
2009-10-19 18:28:16 +00:00
}
}
2010-01-24 15:21:06 +00:00
/**
* Test to make sure comment content is rebuilt.
*/
class CommentContentRebuild extends CommentHelperCase {
public static function getInfo() {
return array(
'name' => 'Comment Rebuild',
'description' => 'Test to make sure the comment content is rebuilt.',
'group' => 'Comment',
);
}
/**
2010-01-25 10:40:00 +00:00
* Test to ensure that the comment's content array is rebuilt for every
* call to comment_view().
2010-01-24 15:21:06 +00:00
*/
function testCommentRebuild() {
// Update the comment settings so preview isn't required.
$this->drupalLogin($this->admin_user);
$this->setCommentSubject(TRUE);
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->drupalLogout();
// Log in as the web user and add the comment.
$this->drupalLogin($this->web_user);
$subject_text = $this->randomName();
$comment_text = $this->randomName();
$comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
$comment_loaded = comment_load($comment->id);
$this->assertTrue($this->commentExists($comment), t('Comment found.'));
// Add the property to the content array and then see if it still exists on build.
$comment_loaded->content['test_property'] = array('#value' => $this->randomString());
2010-01-25 10:40:00 +00:00
$built_content = comment_view($comment_loaded, $this->node);
2010-01-24 15:21:06 +00:00
// This means that the content was rebuilt as the added test property no longer exists.
$this->assertFalse(isset($built_content['test_property']), t('Comment content was emptied before being built.'));
}
2010-01-30 07:59:26 +00:00
}