private function ForumAccessTestCase::testForumAccessCreateForum in Forum Access 6
This function creates a new forum (must be used by the admin user!)
1 call to ForumAccessTestCase::testForumAccessCreateForum()
- ForumAccessTestCase::testForumAccessRun in ./
forum_access.test - The main function which is used to start testing a specific forum configuration.
File
- ./
forum_access.test, line 527 - Test file for forum_access.module.
Class
- ForumAccessTestCase
- This is the base class for forum access testing.
Code
private function testForumAccessCreateForum($options = array()) {
if (is_array($options) && isset($options['anonymous_view']) && isset($options['anonymous_create']) && isset($options['anonymous_update']) && isset($options['anonymous_delete']) && isset($options['authenticated_view']) && isset($options['authenticated_create']) && isset($options['authenticated_update']) && isset($options['authenticated_delete'])) {
$forum_options = array(
'name' => 'Forum name: ' . $this
->randomName(32),
'description' => 'Forum description: ' . $this
->randomName(64),
'forum_access[view][1]' => $options['anonymous_view'],
'forum_access[create][1]' => $options['anonymous_create'],
'forum_access[update][1]' => $options['anonymous_update'],
'forum_access[delete][1]' => $options['anonymous_delete'],
'forum_access[view][2]' => $options['authenticated_view'],
'forum_access[create][2]' => $options['authenticated_create'],
'forum_access[update][2]' => $options['authenticated_update'],
'forum_access[delete][2]' => $options['authenticated_delete'],
);
$html = $this
->drupalPost('admin/content/forum/add/forum', $forum_options, t('Save'));
if ($this
->assertNoText("not authorized", t('@user should be allowed to create new forum: @page', array(
'@user' => $this->loggedInUser ? t('The user') : t('Anonymous'),
'@page' => $this
->getUrl(),
)))) {
$position = strpos($html, $forum_options['name']);
$matches = array();
if ($this
->assert(intval($position) > 0, t("Found 'edit forum' link."))) {
preg_match('/admin\\/content\\/forum\\/edit\\/forum\\/(?<forum_id>\\d+)/', $html, $matches, 0, $position);
$forum_tid = array_key_exists('forum_id', $matches) ? intval($matches['forum_id']) : 0;
if (!$this
->assert($forum_tid > 0, t("Found tid in 'edit forum' link."))) {
$this
->testForumAccessDumpDebugInfo();
}
return $forum_tid;
}
else {
$this
->testForumAccessDumpDebugInfo();
}
}
else {
$this
->testForumAccessDumpDebugInfo();
}
}
return 0;
}