You are here

class PMTaskTestCase in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmtask/pmtask.test \PMTaskTestCase
  2. 7 pmtask/pmtask.test \PMTaskTestCase
  3. 7.2 pmtask/pmtask.test \PMTaskTestCase

Define a test case for PM Task.

Hierarchy

Expanded class hierarchy of PMTaskTestCase

File

pmtask/pmtask.test, line 10
Test definitions for PM Task.

View source
class PMTaskTestCase extends DrupalWebTestCase {

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

  /**
   * Provides standard set up for all test cases.
   */
  public function setUp() {

    // @todo Remove pmorganization dependency.
    parent::setUp('pm', 'pmorganization', 'pmtask');
  }

  /**
   * Test of access controls on Task lists.
   */
  public function testpmtaskAccess() {

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

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

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

  /**
   * Test of Task node creation.
   */
  public function testpmtaskCreate() {

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

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

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

}

Members

Namesort descending Modifiers Type Description Overrides
PMTaskTestCase::getInfo public static function Defines this group of test cases.
PMTaskTestCase::setUp public function Provides standard set up for all test cases.
PMTaskTestCase::testpmtaskAccess public function Test of access controls on Task lists.
PMTaskTestCase::testpmtaskCreate public function Test of Task node creation.
PMTaskTestCase::testpmtaskUninstall public function Tests module uninstall path.