protected function AuthcacheForumTest::createForum in Authenticated User Page Caching (Authcache) 7.2
Creates a forum container or a forum.
See also
1 call to AuthcacheForumTest::createForum()
- 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 103 - Test cases for the Authcache Forum module.
Class
- AuthcacheForumTest
- Tests for markup substitution.
Code
protected 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' => variable_get('forum_nav_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;
}