Commit 3fbe8b72 authored by Dries's avatar Dries
Browse files

- Patch #564642 by Scott Reynolds: added tests for node_rebuild() and comment_rebuild().

parent 8641f9dc
......@@ -1190,3 +1190,42 @@ class CommentRdfaTestCase extends CommentHelperCase {
$this->assertEqual((string)$comment_author[0], $name);
}
}
/**
* 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',
);
}
/**
* Test to ensure that the comment's content array is rebuilt for every call to comment_build().
*/
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());
$built_content = comment_build($comment_loaded, $this->node);
// 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.'));
}
}
\ No newline at end of file
......@@ -1357,3 +1357,31 @@ class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
$this->assertFieldChecked('edit-sticky', 'sticky stayed checked');
}
}
/**
* Test to ensure that a node's content is always rebuilt.
*/
class NodeBuildContent extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Rebuild content',
'description' => 'Test the rebuilding of content for different build modes.',
'group' => 'Node',
);
}
/**
* Test to ensure that a node's content array is rebuilt on every call to node_build_content().
*/
function testNodeRebuildContent() {
$node = $this->drupalCreateNode();
// Set a property in the content array so we can test for its existance later on.
$node->content['test_content_property'] = array('#value' => $this->randomString());
$content = node_build_content($node);
// If the property doesn't exist it means the node->content was rebuilt.
$this->assertFalse(isset($content['test_content_property']), t('Node content was emptied prior to being built.'));
}
}
\ No newline at end of file
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