class PrivatemsgFilterWidgetTestCase

  1. 7-1 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterWidgetTestCase
  2. 7-2 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterWidgetTestCase
  3. 6-2 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterWidgetTestCase

Test filters, tags and inbox/sent handling.

Hierarchy

Expanded class hierarchy of PrivatemsgFilterWidgetTestCase

File

privatemsg_filter/privatemsg_filter.test, line 435
Contains tests for the privatemsg_filter module.

View source
class PrivatemsgFilterWidgetTestCase extends PrivatemsgBaseTestCase {
  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Privatemsg filter widget'),
      'description' => t('Tests the Privatemsg filter widget displayed on message listings'),
      'group' => t('Privatemsg'),
    );
  }

  /**
   * Implements setUp().
   */
  function setUp() {
    parent::setUp('privatemsg', 'privatemsg_filter');
  }

  /**
   * Generic filter widget tests.
   */
  function testAuthorSearch() {
    $user1 = $this->drupalCreateuser(array('read privatemsg', 'write privatemsg', 'tag private messages', 'create private message tags', 'filter private messages'));
    $user2 = $this->drupalCreateuser(array('read privatemsg', 'write privatemsg', 'tag private messages', 'create private message tags', 'filter private messages'));
    $user3 = $this->drupalCreateuser(array('read privatemsg', 'write privatemsg', 'tag private messages', 'create private message tags', 'filter private messages'));

    $this->drupalLogin($user2);
    $this->drupalGet('messages');

    // Make sure the widget is not displayed when there are no messages.
    $this->assertNoFieldById('edit-author');

    // Create a new thread from user 1 through the api.
    $response = privatemsg_new_thread(array($user2), $subject = $this->randomName(10), $this->randomName(20), array('author' => $user1));

    $this->drupalGet('messages');

    // Make sure the widget is now displayed and the message is too.
    $this->assertText($subject);
    $this->assertFieldById('edit-author');

    // Search for user 3 which will find no results but the widget should still be displayed.
    $this->drupalPost(NULL, array('author' => $user3->name), t('Filter'));
    $this->assertNoText($subject);
    $this->assertFieldById('edit-author', $user3->name . ', ');

    // Reset filter widget.
    $this->drupalPost(NULL, array(), t('Reset'));
    $this->assertFieldById('edit-author');
    $this->assertText($subject);

    // Create a new thread through the api.
    $response = privatemsg_new_thread(array($user2), $subject2 = $this->randomName(10), $this->randomName(20), array('author' => $user3));

    // Make sure that the new message is displayed.
    $this->drupalGet('messages');
    $this->assertText($subject2);

    // Search for user 1 which should only display his message.
    $this->drupalPost(NULL, array('author' => $user1->name), t('Filter'));
    $this->assertText($subject);
    $this->assertNoText($subject2);

    // Save the filter and access /messages again - The filter should still be
    // active.
    $this->drupalPost(NULL, array(), t('Save filter'));
    $this->drupalGet('messages');
    $this->assertFieldById('edit-author', $user1->name . ', ');
    $this->assertText($subject);
    $this->assertNoText($subject2);

    // Reset filter widget.
    $this->drupalPost(NULL, array(), t('Reset'));
    $this->assertFieldById('edit-author');
    $this->assertText($subject);
    $this->assertText($subject2);
  }
}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
PrivatemsgBaseTestCase::$profile protected property Use testing profile.
PrivatemsgFilterWidgetTestCase::getInfo public static function Implements getInfo().
PrivatemsgFilterWidgetTestCase::setUp function Implements setUp().
PrivatemsgFilterWidgetTestCase::testAuthorSearch function Generic filter widget tests.