You are here

pmnote.test in Drupal PM (Project Management) 7

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

Test definitions for the PM Note module.

File

pmnote/pmnote.test
View source
<?php

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

/**
 * Test definition for the PM Note module.
 */
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', '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() {

    // Create and login user
    $user = $this
      ->drupalCreateUser(array(
      'Project Management Organization: add',
      'Project Management Organization: view all',
      'Project Management Project: add',
      'Project Management Project: view all',
      'Project Management Task: add',
      'Project Management Task: view all',
      'Project Management note: add',
      'Project Management note: view all',
    ));
    $this
      ->drupalLogin($user);

    // Create organization and invoice
    $org = array(
      'title' => $this
        ->randomName(32),
      'body[und][0][value]' => $this
        ->randomName(64),
    );
    $prj = array(
      'title' => $this
        ->randomName(32),
      'organization_nid' => '1',
    );
    $task = array(
      'title' => $this
        ->randomName(32),
      'body[und][0][value]' => $this
        ->randomName(64),
    );
    $note = array(
      'title' => $this
        ->randomName(32),
      'body[und][0][value]' => $this
        ->randomName(64),
    );
    $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/pmnote', $note, t('Save'));
    $this
      ->assertText(t('Note @title has been created.', array(
      '@title' => $note['title'],
    )));
  }

}

Classes

Namesort descending Description
PMNoteTestCase Test definition for the PM Note module.