You are here

pm.test in Drupal PM (Project Management) 7

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

Tests for the Project Management module

File

pm.test
View source
<?php

/**
 * @file
 * Tests for the Project Management module
 */
class PMTestCase extends DrupalWebTestCase {

  /**
   * Returns meta data for Project Management tests.
   */
  public static function getInfo() {
    return array(
      'name' => 'Project Management functionality',
      'description' => 'Test the functionality of the Project Management base module',
      'group' => 'Project Management',
    );
  }

  /**
   * Standard set up for all tests.
   */
  public function setUp() {
    parent::setUp('pm');
  }

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

  /**
   * Tests access to Project Management settings pages.
   */
  public function testpmAccessSettings() {
    $this
      ->drupalGet('admin/config/pm');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management settings page for anonymous user'));
    $this
      ->drupalGet('admin/config/pm/pm');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management settings page for anonymous user'));
    $basic_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($basic_user);
    $this
      ->drupalGet('admin/config/pm');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management settings page for basic user'));
    $this
      ->drupalGet('admin/config/pm/pm');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management settings page for basic user'));
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management: access administration pages',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('admin/config/pm');
    $this
      ->assertText(t('Project Management'), t('Make sure the correct page has been displayed by checking that the title of the settings page is "Project Management".'));
    $this
      ->drupalGet('admin/config/pm/pm');
    $this
      ->assertText(t('Project Management'), t('Make sure the correct page has been displayed by checking that the title of the settings page is "Project Management".'));
  }

  /**
   * Tests access to Project Management attributes pages.
   */
  public function testpmAttributesAccess() {
    $this
      ->drupalGet('pm/attributes');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Attributes list for anonymous user'));
    $this
      ->drupalGet('pm/attributes/add');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Attributes form for anonymous user'));
    $basic_user = $this
      ->drupalCreateUser();
    $this
      ->drupalLogin($basic_user);
    $this
      ->drupalGet('pm/attributes');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Attributes list for basic user'));
    $this
      ->drupalGet('pm/attributes/add');
    $this
      ->assertResponse(403, t('Make sure access is denied to Project Management Attributes form for basic user'));
    $privileged_user = $this
      ->drupalCreateUser(array(
      'Project Management: access administration pages',
    ));
    $this
      ->drupalLogin($privileged_user);
    $this
      ->drupalGet('pm/attributes');
    $this
      ->assertText(t('Attributes'), t('Make sure the correct page has been displayed by checking that the title is "Attributes".'));
    $this
      ->drupalGet('pm/attributes/add');
    $this
      ->assertText(t('Add a new attribute'), t('Make sure the correct page has been displayed by checking that the title is "Add a new attribute".'));
  }

}

Classes

Namesort descending Description
PMTestCase @file Tests for the Project Management module