opigno_forum_app.test in Opigno Forum App 7
File
opigno_forum_app.test
View source
<?php
class opigno_forum_app_forum_is_created_TestCase extends DrupalWebTestCase {
protected $privileged_user;
protected $nonpriveliged_user;
public static function getInfo() {
return array(
'name' => 'Opigno Forum app',
'description' => 'Web Tests for Opigno Forum app',
'group' => 'Opigno Forum app',
);
}
public function setUp() {
parent::setUp(array(
'opigno_forum_app',
'opigno',
));
$this->privileged_user = $this
->drupalCreateUser(array(
'create course content',
));
$this
->drupalLogin($this->privileged_user);
}
public function test_opigno_forum_app_course_create() {
$edit = array();
$edit['title'] = $this
->randomName(8);
$edit["body[und][0][value]"] = $this
->randomName(16);
$this
->drupalPost('node/add/course', $edit, t('Save'));
$this
->assertText(t('Course @title has been created.', array(
'@title' => $edit['title'],
)));
$taxonomy = taxonomy_get_term_by_name($edit['title'], 'forums');
$this
->assertNotNull($taxonomy, 'Forum was found.');
foreach ($taxonomy as $id => $ataxonomy) {
$this
->drupalGet('forum/' . $id);
$this
->assertText(t('No posts in this forum.'));
}
$this->nonpriveliged_user = $this
->drupalCreateUser();
$this
->drupalLogin($this->nonpriveliged_user);
foreach ($taxonomy as $id => $ataxonomy) {
$this
->drupalGet('forum/' . $id);
$this
->assertText(t('Page not found'));
}
}
}