You are here

pmticket.test in Drupal PM (Project Management) 7.2

Test definitions for PM Ticket.

File

pmticket/pmticket.test
View source
<?php

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

/**
 * Define a test case for PM Ticket.
 */
class PMTicketTestCase extends DrupalWebTestCase {

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

  /**
   * Standard configuration for all test cases.
   */
  public function setUp() {
    parent::setUp('pm', 'pmorganization', 'pmproject', 'pmtask', 'pmticket');
  }

  /**
   * Test case covering access of ticket list.
   */
  public function testpmticketAccess() {
    $this
      ->drupalGet('pm/tickets');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Tickets list for anonymous user'));
    $basic_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($basic_user);
    $this
      ->drupalGet('pm/tickets');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Tickets list for basic user'));
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management Ticket: access',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('pm/tickets');
    $this
      ->assertText(t('Tickets'), t('Make sure the correct page has been displayed by checking that the title is "Tickets".'));
  }

  /**
   * Test case covering creation of pmtickets.
   */
  public function testpmticketCreate() {

    // Log in with permission to create test content.
    $user = $this
      ->drupalCreateUser(array(
      'create pmorganization content',
      'create pmproject content',
      'create pmtask content',
      'create pmticket 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),
    );
    $ticket = 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/pmtask', $task, t('Save'));
    $this
      ->drupalPost('node/add/pmticket', $ticket, t('Save'));
    $this
      ->assertText(t('Ticket @title has been created.', array(
      '@title' => $ticket['title'],
    )));
  }

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

}

Classes

Namesort descending Description
PMTicketTestCase Define a test case for PM Ticket.