You are here

protected function AuthcacheForumTest::createForumTopic in Authenticated User Page Caching (Authcache) 7.2

Creates forum topic.

See also

ForumTestCase::createForumTopic()

1 call to AuthcacheForumTest::createForumTopic()
AuthcacheForumTest::setUp in modules/authcache_forum/authcache_forum.test
Sets up a Drupal site for running functional and integration tests.

File

modules/authcache_forum/authcache_forum.test, line 142
Test cases for the Authcache Forum module.

Class

AuthcacheForumTest
Tests for markup substitution.

Code

protected function createForumTopic($forum, $container = FALSE) {

  // Generate a random subject/body.
  $title = $this
    ->randomName(20);
  $body = $this
    ->randomName(200);
  $langcode = LANGUAGE_NONE;
  $edit = array(
    "title" => $title,
    "body[{$langcode}][0][value]" => $body,
  );
  $tid = $forum['tid'];

  // Create the forum topic, preselecting the forum ID via a URL parameter.
  $this
    ->drupalPost('node/add/forum/' . $tid, $edit, t('Save'));
  $type = t('Forum topic');
  if ($container) {
    $this
      ->assertNoRaw(t('@type %title has been created.', array(
      '@type' => $type,
      '%title' => $title,
    )), 'Forum topic was not created');
    $this
      ->assertRaw(t('The item %title is a forum container, not a forum.', array(
      '%title' => $forum['name'],
    )), 'Error message was shown');
    return;
  }
  else {
    $this
      ->assertRaw(t('@type %title has been created.', array(
      '@type' => $type,
      '%title' => $title,
    )), 'Forum topic was created');
    $this
      ->assertNoRaw(t('The item %title is a forum container, not a forum.', array(
      '%title' => $forum['name'],
    )), 'No error message was shown');
  }

  // Retrieve node object, ensure that the topic was created and in the proper
  // forum.
  $node = $this
    ->drupalGetNodeByTitle($title);
  $this
    ->assertTrue($node != NULL, format_string('Node @title was loaded', array(
    '@title' => $title,
  )));
  $this
    ->assertEqual($node->taxonomy_forums[LANGUAGE_NONE][0]['tid'], $tid, 'Saved forum topic was in the expected forum');

  // View forum topic.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw($title, 'Subject was found');
  $this
    ->assertRaw($body, 'Body was found');
  return $node;
}