summaryrefslogtreecommitdiff
path: root/modules/comment/comment.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-28 18:19:23 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-28 18:19:23 +0000
commitef244365561d38987bb92bd0ab33bfc331156408 (patch)
tree36a696a786aa32c0cbbb8cbfb9530940a3337998 /modules/comment/comment.test
parent52ba5cc84c0d6e47913392a1df666b8b6cd27952 (diff)
downloadbrdo-ef244365561d38987bb92bd0ab33bfc331156408.tar.gz
brdo-ef244365561d38987bb92bd0ab33bfc331156408.tar.bz2
#1005004 by markabur, bfroehle: Fixed critical Editing a comment destroys its creation date
Diffstat (limited to 'modules/comment/comment.test')
-rw-r--r--modules/comment/comment.test39
1 files changed, 34 insertions, 5 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test
index fbef5d7a8..dad144c77 100644
--- a/modules/comment/comment.test
+++ b/modules/comment/comment.test
@@ -519,9 +519,9 @@ class CommentPreviewTest extends CommentHelperCase {
}
/**
- * Test comment edit and preview.
+ * Test comment edit, preview, and save.
*/
- function testCommentEditPreview() {
+ function testCommentEditPreviewSave() {
$langcode = LANGUAGE_NONE;
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
$this->drupalLogin($this->admin_user);
@@ -535,7 +535,9 @@ class CommentPreviewTest extends CommentHelperCase {
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$edit['name'] = $web_user->name;
$edit['date'] = '2008-03-02 17:23 +0300';
- $expected_date = format_date(strtotime($edit['date']));
+ $raw_date = strtotime($edit['date']);
+ $expected_text_date = format_date($raw_date);
+ $expected_form_date = format_date($raw_date, 'custom', 'Y-m-d H:i O');
$comment = $this->postComment($this->node, $edit['subject'], $edit['comment_body[' . $langcode . '][0][value]'], TRUE);
$this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));
@@ -544,13 +546,40 @@ class CommentPreviewTest extends CommentHelperCase {
$this->assertText($edit['subject'], t('Subject displayed.'));
$this->assertText($edit['comment_body[' . $langcode . '][0][value]'], t('Comment displayed.'));
$this->assertText($edit['name'], t('Author displayed.'));
- $this->assertText($expected_date, t('Date displayed.'));
+ $this->assertText($expected_text_date, t('Date displayed.'));
- // Check that the title and body fields are displayed with the correct values.
+ // Check that the subject, comment, author and date fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
$this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
$this->assertFieldByName('name', $edit['name'], t('Author field displayed.'));
$this->assertFieldByName('date', $edit['date'], t('Date field displayed.'));
+
+ // Check that saving a comment produces a success message.
+ $this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Save'));
+ $this->assertText(t('Your comment has been posted.'), t('Comment posted.'));
+
+ // Check that the comment fields are correct after loading the saved comment.
+ $this->drupalGet('comment/' . $comment->id . '/edit');
+ $this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
+ $this->assertFieldByName('comment_body[' . $langcode . '][0][value]', $edit['comment_body[' . $langcode . '][0][value]'], t('Comment field displayed.'));
+ $this->assertFieldByName('name', $edit['name'], t('Author field displayed.'));
+ $this->assertFieldByName('date', $expected_form_date, t('Date field displayed.'));
+
+ // Submit the form using the displayed values.
+ $displayed = array();
+ $displayed['subject'] = (string) current($this->xpath("//input[@id='edit-subject']/@value"));
+ $displayed['comment_body[' . $langcode . '][0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-" . $langcode . "-0-value']"));
+ $displayed['name'] = (string) current($this->xpath("//input[@id='edit-name']/@value"));
+ $displayed['date'] = (string) current($this->xpath("//input[@id='edit-date']/@value"));
+ $this->drupalPost('comment/' . $comment->id . '/edit', $displayed, t('Save'));
+
+ // Check that the saved comment is still correct.
+ $comment_loaded = comment_load($comment->id);
+ $this->assertEqual($comment_loaded->subject, $edit['subject'], t('Subject loaded.'));
+ $this->assertEqual($comment_loaded->comment_body[$langcode][0]['value'], $edit['comment_body[' . $langcode . '][0][value]'], t('Comment body loaded.'));
+ $this->assertEqual($comment_loaded->name, $edit['name'], t('Name loaded.'));
+ $this->assertEqual($comment_loaded->created, $raw_date, t('Date loaded.'));
+
}
}