Creates a forum topic.
string The title of the newly generated topic.
protected function createForumTopics($count = 5) {
$topics = array();
$date = new DrupalDateTime();
$date
->modify('-24 hours');
for ($index = 0; $index < $count; $index++) {
// Generate a random subject/body.
$title = $this
->randomName(20);
$body = $this
->randomName(200);
// Forum posts are ordered by timestamp, so force a unique timestamp by
// changing the date.
$date
->modify('+1 minute');
$langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
'title' => $title,
"body[{$langcode}][0][value]" => $body,
// Forum posts are ordered by timestamp, so force a unique timestamp by
// adding the index.
'date[date]' => $date
->format('Y-m-d'),
'date[time]' => $date
->format('H:i:s'),
);
// Create the forum topic, preselecting the forum ID via a URL parameter.
$this
->drupalPost('node/add/forum/1', $edit, t('Save and publish'));
$topics[] = $title;
}
return $topics;
}