You are here

pmissue.test in Drupal PM (Project Management) 7.2

Same filename and directory in other branches
  1. 8 pmissue/pmissue.test
  2. 7.3 pmissue/pmissue.test

Test definitions for PM Issue.

File

pmissue/pmissue.test
View source
<?php

/**
 * @file
 * Test definitions for PM Issue.
 */

/**
 * Define a test case for PM Issue.
 */
class PMIssueTestCase extends DrupalWebTestCase {

  /**
   * Defines this group of test cases.
   */
  public static function getInfo() {
    return array(
      'name' => t('PM Issue'),
      'description' => t('Test the functionality of the PM Issue module'),
      'group' => 'Project Management',
    );
  }

  /**
   * Provides standard set up for all test cases.
   */
  public function setUp() {
    parent::setUp('pm', 'pmorganization', 'pmproject', 'pmissue');
  }

  /**
   * Test of access controls on Issue lists.
   */
  public function testpmissueAccess() {

    // Anonymous user.
    $this
      ->drupalGet('pm/issues');
    $this
      ->assertResponse(403, 'Access is denied to the anonymous user.');

    // Authenticated user.
    $authenticated_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($authenticated_user);
    $this
      ->drupalGet('pm/issues');
    $this
      ->assertResponse(403, 'Access is denied to the authenticated user.');

    // Privileged user.
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management Issue: access',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('pm/issues');
    $this
      ->assertText(t('Issues'), t('Access granted for the privileged user. Correct page has been confirmed by checking that the title is "Issues".'));
  }

  /**
   * Test of Issue node creation.
   */
  public function testpmissueCreate() {

    // Log in with permission to create test content.
    $user = $this
      ->drupalCreateUser(array(
      'create pmorganization content',
      'create pmproject content',
      'create pmissue content',
    ));
    $this
      ->drupalLogin($user);

    // Create test content.
    $org = array(
      'title' => $this
        ->randomName(32),
    );
    $prj = array(
      'title' => $this
        ->randomName(32),
    );
    $task = array(
      'title' => $this
        ->randomName(32),
    );
    $this
      ->drupalPost('node/add/pmorganization', $org, t('Save'));
    $this
      ->drupalPost('node/add/pmproject', $prj, t('Save'));
    $this
      ->drupalPost('node/add/pmissue', $task, t('Save'));
    $this
      ->assertText(t('Issue @title has been created.', array(
      '@title' => $task['title'],
    )));
  }

  /**
   * Tests module uninstall path.
   */
  public function testpmissueUninstall() {
    $module = array(
      'pmissue',
    );
    module_disable($module);
    drupal_uninstall_modules($module);
  }

}

Classes

Namesort descending Description
PMIssueTestCase Define a test case for PM Issue.