You are here

class PMTestCase in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pm.test \PMTestCase
  2. 7 pm.test \PMTestCase
  3. 7.2 pm.test \PMTestCase

Define a test case for Project Management.

Hierarchy

Expanded class hierarchy of PMTestCase

File

./pm.test, line 10
Test definitions for Project Management.

View source
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'), t('Make sure the correct page has been displayed by checking that the title is "Project Management".'));
  }

  /**
   * 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 module uninstall path.
   */
  public function testpmUninstall() {
    $module = array(
      'pm',
    );
    module_disable($module);
    $result = drupal_uninstall_modules($module);
    $this
      ->AssertTrue($result, t('Module successfully uninstalled.'));
  }

  /**
   * Tests compatibility between submodules.
   */
  public function testpmEnableAll() {
    $submodules = array(
      'pmexpense',
      'pmissue',
      'pmnote',
      'pmorganization',
      'pmperson',
      'pmproject',
      'pmtask',
      'pmteam',
      'pmticket',
      'pmtimetracking',
    );
    $result = module_enable($submodules, TRUE);
    $this
      ->assertTrue($result, t('Modules enabled successfully.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PMTestCase::getInfo public static function Returns meta data for Project Management tests.
PMTestCase::setUp public function Standard set up for all tests.
PMTestCase::testpmAccess public function Tests access to Project Management pages.
PMTestCase::testpmAccessSettings public function Tests access to Project Management settings pages.
PMTestCase::testpmEnableAll public function Tests compatibility between submodules.
PMTestCase::testpmUninstall public function Tests module uninstall path.