You are here

class PMTicketTestCase in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmticket/pmticket.test \PMTicketTestCase
  2. 7 pmticket/pmticket.test \PMTicketTestCase
  3. 7.2 pmticket/pmticket.test \PMTicketTestCase

Define a test case for PM Ticket.

Hierarchy

Expanded class hierarchy of PMTicketTestCase

File

pmticket/pmticket.test, line 10
Test definitions for PM Ticket.

View source
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.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PMTicketTestCase::getInfo public static function Provides metadata about this group of test cases.
PMTicketTestCase::setUp public function Standard configuration for all test cases.
PMTicketTestCase::testpmticketAccess public function Test case covering access of ticket list.
PMTicketTestCase::testpmticketCreate public function Test case covering creation of pmtickets.
PMTicketTestCase::testpmticketUninstall public function Tests module uninstall path.