You are here

public function opigno_forum_app_forum_is_created_TestCase::test_opigno_forum_app_course_create in Opigno Forum App 7

File

./opigno_forum_app.test, line 26

Class

opigno_forum_app_forum_is_created_TestCase

Code

public function test_opigno_forum_app_course_create() {

  // Create node to edit.
  $edit = array();
  $edit['title'] = $this
    ->randomName(8);
  $edit["body[und][0][value]"] = $this
    ->randomName(16);
  $this
    ->drupalPost('node/add/course', $edit, t('Save'));

  // Was the course created?
  $this
    ->assertText(t('Course @title has been created.', array(
    '@title' => $edit['title'],
  )));
  $taxonomy = taxonomy_get_term_by_name($edit['title'], 'forums');

  // Was the forum created?
  $this
    ->assertNotNull($taxonomy, 'Forum was found.');

  /// Can the creator of the course/ group member access the forum
  foreach ($taxonomy as $id => $ataxonomy) {
    $this
      ->drupalGet('forum/' . $id);
    $this
      ->assertText(t('No posts in this forum.'));
  }

  // can a user not in the group access the 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'));
  }
}