function AddTopicToForum::testAddTopicToForum in SimpleTest 6
File
- tests/
forum_module.test, line 171
Class
Code
function testAddTopicToForum() {
// Attempt to create a forum
$web_user = $this
->drupalCreateUserRolePerm(array(
'access administration pages',
'administer forums',
'create forum topics',
));
$this
->drupalLoginUser($web_user);
// Generate a forum
$forum = $this
->createForum();
// Now, we try to create the topic in the forum
// Generate a random subject/body
$title = $this
->randomName(20);
$description = $this
->randomName(200);
$edit = array(
'title' => $title,
'body' => $description,
);
// Double check that the page says it has created the topic
$this
->drupalPost('node/add/forum/' . $forum['tid'], $edit, 'Save');
$type = t('Forum topic');
$this
->assertWantedRaw(t('@type %term has been created.', array(
'%term' => $title,
'@type' => $type,
)), t('New forum topic has been created'));
$this
->assertNoUnwantedRaw(t('The item %term is only a container for forums.', array(
'%term' => $forum['name'],
)), t('No error message shown'));
// Then find the new topic, load it, and make sure the text we chose appears
$new_topic = node_load(array(
'title' => $title,
), null, true);
$this
->drupalGet("node/{$new_topic->nid}");
$this
->assertWantedRaw($title, t('Looking for subject text'));
$this
->assertWantedRaw($description, t('Looking for body text'));
// Delete the topic
node_delete($new_topic->nid);
// Delete the forum we created
if (!empty($forum)) {
taxonomy_del_term($forum['tid']);
}
}