You are here

pmproject.test in Drupal PM (Project Management) 7.2

Test definitions for PM Project.

File

pmproject/pmproject.test
View source
<?php

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

/**
 * Define a test case for PM Project.
 */
class PMProjectTestCase extends DrupalWebTestCase {

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

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

  /**
   * Test case covering access of project list.
   */
  public function testpmprojectAccess() {

    // Anonymous user.
    $this
      ->drupalGet('pm/projects');
    $this
      ->assertResponse(403, 'Access is denied to the anonymous user.');

    // Authenticated user.
    $authenticated_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($authenticated_user);
    $this
      ->drupalGet('pm/projects');
    $this
      ->assertResponse(403, 'Access is denied to the authenticated user.');

    // Privileged user.
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management Project: access',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('pm/projects');
    $this
      ->assertText(t('Projects'), t('Access granted for the privileged user. Correct page has been confirmed by checking that the title is "Projects".'));
  }

  /**
   * Test case covering creation of pmprojects.
   */
  public function testpmprojectCreate() {

    // Log in with permission to create test content.
    $user = $this
      ->drupalCreateUser(array(
      'create pmorganization content',
      'create pmproject content',
    ));
    $this
      ->drupalLogin($user);

    // Create test content.
    $org = array(
      'title' => $this
        ->randomName(32),
    );
    $prj = array(
      'title' => $this
        ->randomName(32),
      'pmproject_parent[und]' => '1',
    );
    $this
      ->drupalPost('node/add/pmorganization', $org, t('Save'));
    $this
      ->drupalPost('node/add/pmproject', $prj, t('Save'));
    $this
      ->assertText(t('Project @title has been created.', array(
      '@title' => $prj['title'],
    )));
  }

}

Classes

Namesort descending Description
PMProjectTestCase Define a test case for PM Project.