/** * Creates a forum topic. * * @return 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->randomMachineName(20); $body = $this->randomMachineName(200); // Forum posts are ordered by timestamp, so force a unique timestamp by // changing the date. $date->modify('+1 minute'); $edit = array('title[0][value]' => $title, 'body[0][value]' => $body, 'created[0][value][date]' => $date->format('Y-m-d'), 'created[0][value][time]' => $date->format('H:i:s')); // Create the forum topic, preselecting the forum ID via a URL parameter. $this->drupalPostForm('node/add/forum', $edit, t('Save and publish'), array('query' => array('forum_id' => 1))); $topics[] = $title; } return $topics; }