summaryrefslogtreecommitdiffstats
path: root/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
blob: d4aba03a77c994745ccd54c450172b48e451e9c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
<?php

/**
 * @file
 * Tests for forum.module.
 */

namespace Drupal\forum\Tests;

use Drupal\node\Plugin\Core\Entity\Node;
use Drupal\simpletest\WebTestBase;

/**
 * Provides automated tests for the Forum module.
 */
class ForumTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu', 'help');

  /**
   * A user with various administrative privileges.
   */
  protected $admin_user;

  /**
   * A user that can create forum topics and edit its own topics.
   */
  protected $edit_own_topics_user;

  /**
   * A user that can create, edit, and delete forum topics.
   */
  protected $edit_any_topics_user;

  /**
   * A user with no special privileges.
   */
  protected $web_user;

  /**
   * An array representing a forum container.
   */
  protected $forumContainer;

  /**
   * An array representing a forum.
   */
  protected $forum;

  /**
   * An array representing a root forum.
   */
  protected $root_forum;

  /**
   * An array of forum topic node IDs.
   */
  protected $nids;

  public static function getInfo() {
    return array(
      'name' => 'Forum functionality',
      'description' => 'Create, view, edit, delete, and change forum entries and verify its consistency in the database.',
      'group' => 'Forum',
    );
  }

  function setUp() {
    parent::setUp();

    // Create users.
    $this->admin_user = $this->drupalCreateUser(array(
      'access administration pages',
      'administer modules',
      'administer blocks',
      'administer forums',
      'administer menu',
      'administer taxonomy',
      'create forum content',
    ));
    $this->edit_any_topics_user = $this->drupalCreateUser(array(
      'access administration pages',
      'create forum content',
      'edit any forum content',
      'delete any forum content',
    ));
    $this->edit_own_topics_user = $this->drupalCreateUser(array(
      'create forum content',
      'edit own forum content',
      'delete own forum content',
    ));
    $this->web_user = $this->drupalCreateUser();
  }

  /**
   * Tests disabling and re-enabling the Forum module.
   */
  function testEnableForumField() {
    $this->drupalLogin($this->admin_user);

    // Disable the Forum module.
    $edit = array();
    $edit['modules[Core][forum][enable]'] = FALSE;
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
    $this->rebuildContainer();
    $this->assertFalse(module_exists('forum'), 'Forum module is not enabled.');

    // Attempt to re-enable the Forum module and ensure it does not try to
    // recreate the taxonomy_forums field.
    $edit = array();
    $edit['modules[Core][forum][enable]'] = 'forum';
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
    $this->rebuildContainer();
    $this->assertTrue(module_exists('forum'), 'Forum module is enabled.');
  }

  /**
   * Tests forum functionality through the admin and user interfaces.
   */
  function testForum() {
    //Check that the basic forum install creates a default forum topic
    $this->drupalGet("/forum");
    // Look for the "General discussion" default forum
    $this->assertText(t("General discussion"), "Found the default forum at the /forum listing");

    // Do the admin tests.
    $this->doAdminTests($this->admin_user);

    $this->generateForumTopics($this->forum);

    // Login an unprivileged user to view the forum topics and generate an
    // active forum topics list.
    $this->drupalLogin($this->web_user);
    // Verify that this user is shown a message that they may not post content.
    $this->drupalGet('forum/' . $this->forum['tid']);
    $this->assertText(t('You are not allowed to post new content in the forum'), "Authenticated user without permission to post forum content is shown message in local tasks to that effect.");


    // Log in, and do basic tests for a user with permission to edit any forum
    // content.
    $this->doBasicTests($this->edit_any_topics_user, TRUE);
    // Create a forum node authored by this user.
    $any_topics_user_node = $this->createForumTopic($this->forum, FALSE);

    // Log in, and do basic tests for a user with permission to edit only its
    // own forum content.
    $this->doBasicTests($this->edit_own_topics_user, FALSE);
    // Create a forum node authored by this user.
    $own_topics_user_node = $this->createForumTopic($this->forum, FALSE);
    // Verify that this user cannot edit forum content authored by another user.
    $this->verifyForums($this->edit_any_topics_user, $any_topics_user_node, FALSE, 403);

    // Verify that this user is shown a local task to add new forum content.
    $this->drupalGet('forum');
    $this->assertLink(t('Add new Forum topic'));
    $this->drupalGet('forum/' . $this->forum['tid']);
    $this->assertLink(t('Add new Forum topic'));

    // Login a user with permission to edit any forum content.
    $this->drupalLogin($this->edit_any_topics_user);
    // Verify that this user can edit forum content authored by another user.
    $this->verifyForums($this->edit_own_topics_user, $own_topics_user_node, TRUE);

    // Verify the topic and post counts on the forum page.
    $this->drupalGet('forum');

    // Verify row for testing forum.
    $forum_arg = array(':forum' => 'forum-list-' . $this->forum['tid']);

    // Topics cell contains number of topics and number of unread topics.
    $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]', $forum_arg);
    $topics = $this->xpath($xpath);
    $topics = trim($topics[0]);
    $this->assertEqual($topics, '6', 'Number of topics found.');

    // Verify the number of unread topics.
    $unread_topics = _forum_topics_unread($this->forum['tid'], $this->edit_any_topics_user->uid);
    $unread_topics = format_plural($unread_topics, '1 new post', '@count new posts');
    $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg);
    $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.');
    // Verify that the forum name is in the unread topics text.
    $xpath = $this->buildXPathQuery('//tr[@id=:forum]//em[@class="placeholder"]', $forum_arg);
    $this->assertFieldByXpath($xpath, $this->forum['name'], 'Forum name found in unread topics text.');

    // Verify total number of posts in forum.
    $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="posts"]', $forum_arg);
    $this->assertFieldByXPath($xpath, '6', 'Number of posts found.');

    // Test loading multiple forum nodes on the front page.
    $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content', 'post comments')));
    $this->drupalPost('admin/structure/types/manage/forum', array('node_options[promote]' => 'promote'), t('Save content type'));
    $this->createForumTopic($this->forum, FALSE);
    $this->createForumTopic($this->forum, FALSE);
    $this->drupalGet('node');

    // Test adding a comment to a forum topic.
    $node = $this->createForumTopic($this->forum, FALSE);
    $edit = array();
    $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
    $this->drupalPost("node/$node->nid", $edit, t('Save'));
    $this->assertResponse(200);

    // Test editing a forum topic that has a comment.
    $this->drupalLogin($this->edit_any_topics_user);
    $this->drupalGet('forum/' . $this->forum['tid']);
    $this->drupalPost("node/$node->nid/edit", array(), t('Save'));
    $this->assertResponse(200);
  }

  /**
   * Tests that forum nodes can't be added without a parent.
   *
   * Verifies that forum nodes are not created without choosing "forum" from the
   * select list.
   */
  function testAddOrphanTopic() {
    // Must remove forum topics to test creating orphan topics.
    $vid = config('forum.settings')->get('vocabulary');
    $tree = taxonomy_get_tree($vid);
    foreach ($tree as $term) {
      taxonomy_term_delete($term->tid);
    }

    // Create an orphan forum item.
    $this->drupalLogin($this->admin_user);
    $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save'));

    $nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
    $this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');

    // Reset the defaults for future tests.
    module_enable(array('forum'));
  }

  /**
   * Runs admin tests on the admin user.
   *
   * @param object $user
   *   The logged-in user.
   */
  private function doAdminTests($user) {
    // Login the user.
    $this->drupalLogin($user);

    // Retrieve forum menu id.
    $mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'forum' AND menu_name = 'tools' AND module = 'system' ORDER BY mlid ASC", 0, 1)->fetchField();

    // Add forum to the Tools menu.
    $edit = array();
    $this->drupalPost('admin/structure/menu/manage/tools', $edit, t('Save configuration'));
    $this->assertResponse(200);

    // Edit forum taxonomy.
    // Restoration of the settings fails and causes subsequent tests to fail.
    $this->forumContainer = $this->editForumTaxonomy();
    // Create forum container.
    $this->forumContainer = $this->createForum('container');
    // Verify "edit container" link exists and functions correctly.
    $this->drupalGet('admin/structure/forum');
    $this->clickLink('edit container');
    $this->assertRaw('Edit container', 'Followed the link to edit the container');
    // Create forum inside the forum container.
    $this->forum = $this->createForum('forum', $this->forumContainer['tid']);
    // Verify the "edit forum" link exists and functions correctly.
    $this->drupalGet('admin/structure/forum');
    $this->clickLink('edit forum');
    $this->assertRaw('Edit forum', 'Followed the link to edit the forum');
    // Navigate back to forum structure page.
    $this->drupalGet('admin/structure/forum');
    // Create second forum in container.
    $this->delete_forum = $this->createForum('forum', $this->forumContainer['tid']);
    // Save forum overview.
    $this->drupalPost('admin/structure/forum/', array(), t('Save'));
    $this->assertRaw(t('The configuration options have been saved.'));
    // Delete this second forum.
    $this->deleteForum($this->delete_forum['tid']);
    // Create forum at the top (root) level.
    $this->root_forum = $this->createForum('forum');

    // Test vocabulary form alterations.
    $this->drupalGet('admin/structure/taxonomy/forums/edit');
    $this->assertFieldByName('op', t('Save'), 'Save button found.');
    $this->assertNoFieldByName('op', t('Delete'), 'Delete button not found.');

    // Test term edit form alterations.
    $this->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit');
    // Test parent field been hidden by forum module.
    $this->assertNoField('parent[]', 'Parent field not found.');

    // Create a default vocabulary named "Tags".
    $description = 'Use tags to group articles on similar topics into categories.';
    $help = 'Enter a comma-separated list of words to describe your content.';
    $vocabulary = entity_create('taxonomy_vocabulary', array(
      'name' => 'Tags',
      'description' => $description,
      'vid' => 'tags',
      'langcode' => language_default()->langcode,
      'help' => $help,
    ));
    taxonomy_vocabulary_save($vocabulary);
    // Test tags vocabulary form is not affected.
    $this->drupalGet('admin/structure/taxonomy/tags/edit');
    $this->assertFieldByName('op', t('Save'), 'Save button found.');
    $this->assertFieldByName('op', t('Delete'), 'Delete button found.');
    // Test tags vocabulary term form is not affected.
    $this->drupalGet('admin/structure/taxonomy/tags/add');
    $this->assertField('parent[]', 'Parent field found.');
    // Test relations widget exists.
    $relations_widget = $this->xpath("//details[@id='edit-relations']");
    $this->assertTrue(isset($relations_widget[0]), 'Relations widget element found.');
  }

  /**
   * Edits the forum taxonomy.
   */
  function editForumTaxonomy() {
    // Backup forum taxonomy.
    $vid = config('forum.settings')->get('vocabulary');
    $original_settings = taxonomy_vocabulary_load($vid);

    // Generate a random name/description.
    $title = $this->randomName(10);
    $description = $this->randomName(100);

    $edit = array(
      'name' => $title,
      'description' => $description,
    );

    // Edit the vocabulary.
    $this->drupalPost('admin/structure/taxonomy/' . $original_settings->id() . '/edit', $edit, t('Save'));
    $this->assertResponse(200);
    $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), 'Vocabulary was edited');

    // Grab the newly edited vocabulary.
    $this->container->get('plugin.manager.entity')->getStorageController('taxonomy_vocabulary')->resetCache();
    $current_settings = taxonomy_vocabulary_load($vid);

    // Make sure we actually edited the vocabulary properly.
    $this->assertEqual($current_settings->name, $title, 'The name was updated');
    $this->assertEqual($current_settings->description, $description, 'The description was updated');

    // Restore the original vocabulary.
    taxonomy_vocabulary_save($original_settings);
    drupal_static_reset('taxonomy_vocabulary_load');
    $current_settings = taxonomy_vocabulary_load($vid);
    $this->assertEqual($current_settings->name, $original_settings->name, 'The original vocabulary settings were restored');
  }

  /**
   * Creates a forum container or a forum.
   *
   * @param $type
   *   The forum type (forum container or forum).
   * @param $parent
   *   The forum parent. This defaults to 0, indicating a root forum.
   *
   * @return
   *   The created taxonomy term data.
   */
  function createForum($type, $parent = 0) {
    // Generate a random name/description.
    $name = $this->randomName(10);
    $description = $this->randomName(100);

    $edit = array(
      'name' => $name,
      'description' => $description,
      'parent[0]' => $parent,
      'weight' => '0',
    );

    // Create forum.
    $this->drupalPost('admin/structure/forum/add/' . $type, $edit, t('Save'));
    $this->assertResponse(200);
    $type = ($type == 'container') ? 'forum container' : 'forum';
    $this->assertRaw(
      t(
        'Created new @type %term.',
        array('%term' => $name, '@type' => t($type))
      ),
      format_string('@type was created', array('@type' => ucfirst($type)))
    );

    // Verify forum.
    $term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description = :desc", array(':vid' => config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc();
    $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database');

    // Verify forum hierarchy.
    $tid = $term['tid'];
    $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", array(':tid' => $tid))->fetchField();
    $this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container');

    return $term;
  }

  /**
   * Deletes a forum.
   *
   * @param $tid
   *   The forum ID.
   */
  function deleteForum($tid) {
    // Delete the forum.
    $this->drupalPost('admin/structure/forum/edit/forum/' . $tid, array(), t('Delete'));
    $this->drupalPost(NULL, array(), t('Delete'));

    // Assert that the forum no longer exists.
    $this->drupalGet('forum/' . $tid);
    $this->assertResponse(404, 'The forum was not found');

    // Assert that the associated term has been removed from the
    // forum_containers variable.
    $containers = config('forum.settings')->get('containers');
    $this->assertFalse(in_array($tid, $containers), 'The forum_containers variable has been updated.');
  }

  /**
   * Runs basic tests on the indicated user.
   *
   * @param $user
   *   The logged in user.
   * @param $admin
   *   User has 'access administration pages' privilege.
   */
  private function doBasicTests($user, $admin) {
    // Login the user.
    $this->drupalLogin($user);
    // Attempt to create forum topic under a container.
    $this->createForumTopic($this->forumContainer, TRUE);
    // Create forum node.
    $node = $this->createForumTopic($this->forum, FALSE);
    // Verify the user has access to all the forum nodes.
    $this->verifyForums($user, $node, $admin);
  }

  /**
   * Creates a forum topic.
   *
   * @param array $forum
   *   A forum array.
   * @param boolean $container
   *   TRUE if $forum is a container; FALSE otherwise.
   *
   * @return object
   *   The created topic node.
   */
  function createForumTopic($forum, $container = FALSE) {
    // Generate a random subject/body.
    $title = $this->randomName(20);
    $body = $this->randomName(200);

    $langcode = LANGUAGE_NOT_SPECIFIED;
    $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_NOT_SPECIFIED][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;
  }

  /**
   * Verifies that the logged in user has access to a forum node.
   *
   * @param $node_user
   *   The user who creates the node.
   * @param Drupal\node\Node $node
   *   The node being checked.
   * @param $admin
   *   Boolean to indicate whether the user can 'access administration pages'.
   * @param $response
   *   The exptected HTTP response code.
   */
  private function verifyForums($node_user, Node $node, $admin, $response = 200) {
    $response2 = ($admin) ? 200 : 403;

    // View forum help node.
    $this->drupalGet('admin/help/forum');
    $this->assertResponse($response2);
    if ($response2 == 200) {
      $this->assertTitle(t('Forum | Drupal'), 'Forum help title was displayed');
      $this->assertText(t('Forum'), 'Forum help node was displayed');
    }

    // View forum container page.
    $this->verifyForumView($this->forumContainer);
    // View forum page.
    $this->verifyForumView($this->forum, $this->forumContainer);
    // View root forum page.
    $this->verifyForumView($this->root_forum);

    // View forum node.
    $this->drupalGet('node/' . $node->nid);
    $this->assertResponse(200);
    $this->assertTitle($node->label() . ' | Drupal', 'Forum node was displayed');
    $breadcrumb = array(
      l(t('Home'), NULL),
      l(t('Forums'), 'forum'),
      l($this->forumContainer['name'], 'forum/' . $this->forumContainer['tid']),
      l($this->forum['name'], 'forum/' . $this->forum['tid']),
    );
    $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');

    // View forum edit node.
    $this->drupalGet('node/' . $node->nid . '/edit');
    $this->assertResponse($response);
    if ($response == 200) {
      $this->assertTitle('Edit Forum topic ' . $node->label() . ' | Drupal', 'Forum edit node was displayed');
    }

    if ($response == 200) {
      // Edit forum node (including moving it to another forum).
      $edit = array();
      $langcode = LANGUAGE_NOT_SPECIFIED;
      $edit["title"] = 'node/' . $node->nid;
      $edit["body[$langcode][0][value]"] = $this->randomName(256);
      // Assume the topic is initially associated with $forum.
      $edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid'];
      $edit['shadow'] = TRUE;
      $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
      $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title"])), 'Forum node was edited');

      // Verify topic was moved to a different forum.
      $forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
        ':nid' => $node->nid,
        ':vid' => $node->vid,
      ))->fetchField();
      $this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum');

      // Delete forum node.
      $this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
      $this->assertResponse($response);
      $this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title'])), 'Forum node was deleted');
    }
  }

  /**
   * Verifies the display of a forum page.
   *
   * @param $forum
   *   A row from the taxonomy_term_data table in an array.
   * @param $parent
   *   (optional) An array representing the forum's parent.
   */
  private function verifyForumView($forum, $parent = NULL) {
    // View forum page.
    $this->drupalGet('forum/' . $forum['tid']);
    $this->assertResponse(200);
    $this->assertTitle($forum['name'] . ' | Drupal');

    $breadcrumb = array(
      l(t('Home'), NULL),
      l(t('Forums'), 'forum'),
    );
    if (isset($parent)) {
      $breadcrumb[] = l($parent['name'], 'forum/' . $parent['tid']);
    }

    $this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)));
  }

  /**
   * Generates forum topics.
   *
   * @param array $forum
   *   The forum array (a row from taxonomy_term_data table).
   */
  private function generateForumTopics($forum) {
    $this->nids = array();
    for ($i = 0; $i < 5; $i++) {
      $node = $this->createForumTopic($this->forum, FALSE);
      $this->nids[] = $node->nid;
    }
  }
}