Commit 945efa05 authored by webchick's avatar webchick

Issue #1374090 by droplet, Pancho, G.I.Joe, marthinal, brenda003, jfhovinne:...

Issue #1374090 by droplet, Pancho, G.I.Joe, marthinal, brenda003, jfhovinne: Fixed Editing a comment still changes creation date.
parent f31fbaa2
......@@ -110,7 +110,6 @@ public function form(array $form, array &$form_state) {
if ($is_admin) {
$author = $comment->name->value;
$status = (isset($comment->status->value) ? $comment->status->value : COMMENT_NOT_PUBLISHED);
$date = (!empty($comment->date) ? $comment->date : DrupalDateTime::createFromTimestamp($comment->created->value));
if (empty($form_state['comment_preview'])) {
$form['#title'] = $this->t('Edit comment %title', array(
'%title' => $comment->subject->value,
......@@ -125,7 +124,11 @@ public function form(array $form, array &$form_state) {
$author = ($comment->name->value ? $comment->name->value : '');
}
$status = ($this->currentUser->hasPermission('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED);
$date = '';
}
$date = '';
if ($comment->id()) {
$date = !empty($comment->date) ? $comment->date : DrupalDateTime::createFromTimestamp($comment->created->value);
}
// Add the author name field depending on the current user.
......
......@@ -102,7 +102,7 @@ function testCommentPreview() {
* Tests comment edit, preview, and save.
*/
function testCommentEditPreviewSave() {
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
......@@ -164,6 +164,17 @@ function testCommentEditPreviewSave() {
$this->assertEqual($comment_loaded->comment_body->value, $edit['comment_body[0][value]'], 'Comment body loaded.');
$this->assertEqual($comment_loaded->name->value, $edit['name'], 'Name loaded.');
$this->assertEqual($comment_loaded->created->value, $raw_date, 'Date loaded.');
$this->drupalLogout();
// Check that the date and time of the comment are correct when edited by
// non-admin users.
$user_edit = array();
$expected_created_time = $comment_loaded->created->value;
$this->drupalLogin($web_user);
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $user_edit, t('Save'));
$comment_loaded = comment_load($comment->id(), TRUE);
$this->assertEqual($comment_loaded->created->value, $expected_created_time, 'Expected date and time for comment edited.');
$this->drupalLogout();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment