You are here

pmnote.test in Drupal PM (Project Management) 7.2

Same filename and directory in other branches
  1. 8 pmnote/pmnote.test
  2. 7.3 pmnote/pmnote.test
  3. 7 pmnote/pmnote.test

Test definitions for PM Note.

File

pmnote/pmnote.test
View source
<?php

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

/**
 * Define a test case for PM Note.
 */
class PMNoteTestCase extends DrupalWebTestCase {

  /**
   * Provides test meta-data.
   */
  public static function getInfo() {
    return array(
      'name' => t('PM Note Functionality'),
      'description' => t('Test the functionality of the PM Note module'),
      'group' => 'Project Management',
    );
  }

  /**
   * Set up of test environment.
   */
  public function setUp() {
    parent::setUp('views', 'pm', 'pmorganization', 'pmproject', 'pmtask', 'pmticket', 'pmnote');
  }

  /**
   * Access test case.
   */
  public function testpmnoteAccess() {
    $this
      ->drupalGet('pm/notes');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Notes list for anonymous user'));
    $basic_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($basic_user);
    $this
      ->drupalGet('pm/notes');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Notes list for basic user'));
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management note: access',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('pm/notes');
    $this
      ->assertText(t('Notes'), t('Make sure the correct page has been displayed by checking that the title is "Notes".'));
  }

  /**
   * Node creation test case.
   */
  public function testpmnoteCreate() {

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

  /**
   * Tests module uninstall path.
   */
  public function testpmnoteUninstall() {
    $module = array(
      'pmnote',
    );
    module_disable($module);
    Drupal_uninstall_modules($module);
  }

}

Classes

Namesort descending Description
PMNoteTestCase Define a test case for PM Note.