You are here

class PMOrganizationTestCase in Drupal PM (Project Management) 8

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

Define a test case for PM Organization.

Hierarchy

Expanded class hierarchy of PMOrganizationTestCase

File

pmorganization/pmorganization.test, line 10
Test definitions for PM Organization.

View source
class PMOrganizationTestCase extends DrupalWebTestCase {

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

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

  /**
   * Test case ensuring that the list view is present.
   */
  public function testpmorganizationList() {

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

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

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

  /**
   * Test case ensuring that organization nodes can be created.
   */
  public function testpmorganizationCreate() {

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

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

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

}

Members

Namesort descending Modifiers Type Description Overrides
PMOrganizationTestCase::getInfo public static function Provides metadata about this group of test cases.
PMOrganizationTestCase::setUp public function Standard configuration for all test cases.
PMOrganizationTestCase::testpmorganizationCreate public function Test case ensuring that organization nodes can be created.
PMOrganizationTestCase::testpmorganizationList public function Test case ensuring that the list view is present.
PMOrganizationTestCase::testpmorganizationUninstall public function Tests module uninstall path.