You are here

pmproject.test in Drupal PM (Project Management) 7.3

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', '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 pmproject content',
    ));
    $this
      ->drupalLogin($user);

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

  /**
   * Tests module uninstall path.
   */
  public function testpmprojectUninstall() {
    $module = array(
      'pmproject',
    );
    module_disable($module);
    $result = drupal_uninstall_modules($module);
    $this
      ->AssertTrue($result, t('Module successfully uninstalled.'));
  }

}

Classes

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