You are here

class PMProjectTestCase in Drupal PM (Project Management) 8

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

Define a test case for PM Project.

Hierarchy

Expanded class hierarchy of PMProjectTestCase

File

pmproject/pmproject.test, line 10
Test definitions for PM Project.

View source
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.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PMProjectTestCase::getInfo public static function Provides metadata about this group of test cases.
PMProjectTestCase::setUp public function Standard configuration for all test cases.
PMProjectTestCase::testpmprojectAccess public function Test case covering access of project list.
PMProjectTestCase::testpmprojectCreate public function Test case covering creation of pmprojects.
PMProjectTestCase::testpmprojectUninstall public function Tests module uninstall path.