You are here

class PMNoteTestCase in Drupal PM (Project Management) 8

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

Define a test case for PM Note.

Hierarchy

Expanded class hierarchy of PMNoteTestCase

File

pmnote/pmnote.test, line 10
Test definitions for PM Note.

View source
class PMNoteTestCase extends DrupalWebTestCase {

  /**
   * Provides test meta-data.
   */
  public static function getInfo() {
    return array(
      'name' => t('PM Note Functionality'),
      'description' => t('Test the functionality of the PM Note module'),
      'group' => 'Project Management',
    );
  }

  /**
   * Set up of test environment.
   */
  public function setUp() {
    parent::setUp('views', 'pm', 'pmnote');
  }

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

  /**
   * Node creation test case.
   */
  public function testpmnoteCreate() {

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

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

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

}

Members

Namesort descending Modifiers Type Description Overrides
PMNoteTestCase::getInfo public static function Provides test meta-data.
PMNoteTestCase::setUp public function Set up of test environment.
PMNoteTestCase::testpmnoteAccess public function Access test case.
PMNoteTestCase::testpmnoteCreate public function Node creation test case.
PMNoteTestCase::testpmnoteUninstall public function Tests module uninstall path.