Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
70d6b336
Commit
70d6b336
authored
15 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#524652
follow-up by tic2000 and yched: Fix comment preview bug and add tests.
parent
0355caac
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/comment/comment.module
+4
-4
4 additions, 4 deletions
modules/comment/comment.module
modules/comment/comment.test
+77
-0
77 additions, 0 deletions
modules/comment/comment.test
with
81 additions
and
4 deletions
modules/comment/comment.module
+
4
−
4
View file @
70d6b336
...
@@ -1882,10 +1882,10 @@ function comment_preview($comment) {
...
@@ -1882,10 +1882,10 @@ function comment_preview($comment) {
$comment
->
format
=
$comment
->
comment_format
;
$comment
->
format
=
$comment
->
comment_format
;
// Attach the user and time information.
// Attach the user and time information.
if
(
!
empty
(
$
edit
[
'
author
'
]
))
{
if
(
!
empty
(
$
comment
->
author
))
{
$account
=
user_load_by_name
(
$
edit
[
'
author
'
]
);
$account
=
user_load_by_name
(
$
comment
->
author
);
}
}
elseif
(
$user
->
uid
&&
!
isset
(
$
edit
[
'
is_anonymous
'
]
))
{
elseif
(
$user
->
uid
&&
!
isset
(
$
comment
->
is_anonymous
))
{
$account
=
$user
;
$account
=
$user
;
}
}
...
@@ -1897,7 +1897,7 @@ function comment_preview($comment) {
...
@@ -1897,7 +1897,7 @@ function comment_preview($comment) {
$comment
->
name
=
variable_get
(
'anonymous'
,
t
(
'Anonymous'
));
$comment
->
name
=
variable_get
(
'anonymous'
,
t
(
'Anonymous'
));
}
}
$comment
->
timestamp
=
!
empty
(
$
edit
[
'
timestamp
'
]
)
?
$
edit
[
'
timestamp
'
]
:
REQUEST_TIME
;
$comment
->
timestamp
=
!
empty
(
$
comment
->
timestamp
)
?
$
comment
->
timestamp
:
REQUEST_TIME
;
$comment
->
in_preview
=
TRUE
;
$comment
->
in_preview
=
TRUE
;
$comment_build
=
comment_build
(
$comment
);
$comment_build
=
comment_build
(
$comment
);
$comment_build
+=
array
(
$comment_build
+=
array
(
...
...
This diff is collapsed.
Click to expand it.
modules/comment/comment.test
+
77
−
0
View file @
70d6b336
...
@@ -361,6 +361,83 @@ class CommentInterfaceTest extends CommentHelperCase {
...
@@ -361,6 +361,83 @@ class CommentInterfaceTest extends CommentHelperCase {
}
}
}
}
/**
* 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
()
{
// 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
);
$edit
[
'comment'
]
=
$this
->
randomName
(
16
);
$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.'
));
$this
->
assertText
(
$edit
[
'comment'
],
t
(
'Comment displayed.'
));
// Check that the title and body fields are displayed with the correct values.
$this
->
assertFieldByName
(
'subject'
,
$edit
[
'subject'
],
t
(
'Subject field displayed.'
));
$this
->
assertFieldByName
(
'comment'
,
$edit
[
'comment'
],
t
(
'Comment field displayed.'
));
}
/**
* Test comment edit and preview.
*/
function
testCommentEditPreview
()
{
$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.'
));
$edit
=
array
();
$edit
[
'subject'
]
=
$this
->
randomName
(
8
);
$edit
[
'comment'
]
=
$this
->
randomName
(
16
);
$edit
[
'author'
]
=
$web_user
->
name
;
$edit
[
'date'
]
=
'2008-03-02 17:23 +0300'
;
$expected_date
=
format_date
(
strtotime
(
$edit
[
'date'
]));
$comment
=
$this
->
postComment
(
$this
->
node
,
$edit
[
'subject'
],
$edit
[
'comment'
],
TRUE
);
$this
->
drupalPost
(
'comment/edit/'
.
$comment
->
id
,
$edit
,
t
(
'Preview'
));
// 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.'
));
$this
->
assertText
(
$edit
[
'comment'
],
t
(
'Comment displayed.'
));
$this
->
assertText
(
$edit
[
'author'
],
t
(
'Author displayed.'
));
$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.'
));
$this
->
assertFieldByName
(
'comment'
,
$edit
[
'comment'
],
t
(
'Comment field displayed.'
));
$this
->
assertFieldByName
(
'author'
,
$edit
[
'author'
],
t
(
'Author field displayed.'
));
$this
->
assertFieldByName
(
'date'
,
$edit
[
'date'
],
t
(
'Date field displayed.'
));
}
}
class
CommentAnonymous
extends
CommentHelperCase
{
class
CommentAnonymous
extends
CommentHelperCase
{
public
static
function
getInfo
()
{
public
static
function
getInfo
()
{
return
array
(
return
array
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment