You are here

pmticket.test in Drupal PM (Project Management) 7.3

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() {

    // @todo Remove pmorganization dependency.
    parent::setUp('pm', 'pmorganization', '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 pmticket content',
    ));
    $this
      ->drupalLogin($user);

    // Create test content.
    $ticket = array(
      'title' => $this
        ->randomName(32),
    );
    $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);
    $result = drupal_uninstall_modules($module);
    $this
      ->AssertTrue($result, t('Module successfully uninstalled.'));
  }

}

Classes

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