class PrivatemsgFilterTestCase

  1. 1 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterTestCase
  2. 7-1 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterTestCase
  3. 7-2 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterTestCase
  4. 6-2 privatemsg_filter/privatemsg_filter.test PrivatemsgFilterTestCase

Test filters, tags and inbox/sent handling.

Hierarchy

Expanded class hierarchy of PrivatemsgFilterTestCase

File

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

View source
class PrivatemsgFilterTestCase extends PrivatemsgBaseTestCase {
  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Privatemsg Filter functionality.'),
      'description' => t('Test filters, tags and inbox/sent handling'),
      'group' => t('Privatemsg'),
    );
  }

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

  /**
   * Test correct handling of read all permissions.
   */
  function testInboxSentHandling() {
    $author = $this->drupalCreateUser(array('write privatemsg', 'read privatemsg', 'delete privatemsg'));
    $recipient = $this->drupalCreateUser(array('write privatemsg', 'read privatemsg'));

    // Create new message.
    $edit = array(
      'recipient' => $recipient->name,
      'subject' => $this->randomName(20),
      'body[value]' => $this->randomName(100),
    );
    $this->drupalLogin($author);
    $this->drupalPost('messages/new', $edit, t('Send message'));
    $this->assertText(t('A message has been sent to @recipients.', array('@recipients' => $recipient->name)), t('Message sent confirmation displayed'));

    // Validate that the message is not displayed in the inbox of the author
    // but in the sent list.
    $this->drupalGet('messages');
    $this->assertNoText($edit['subject'], t('Thread not displayed in inbox for author.'));
    $this->drupalGet('messages/sent');
    $this->assertText($edit['subject'], t('Thread displayed in "Sent messages" for author.'));
    $this->drupalGet('messages/list');
    $this->assertText($edit['subject'], t('Thread displayed in "All messages" for author.'));

    // Write a reply as recipient.
    $this->drupalLogin($recipient);
    $this->drupalGet('messages');
    $this->assertText($edit['subject'], t('Thread displayed in inbox for recipient.'));
    $this->drupalGet('messages/sent');
    $this->assertNoText($edit['subject'], t('Thread not displayed in "Sent messages" for recipient.'));
    $this->drupalGet('messages/list');
    $this->assertText($edit['subject'], t('Thread displayed in "All messages." for recipient.'));

    // Navigate to the new message.
    $this->clickLink($edit['subject']);
    $response = array('body[value]' => $this->randomName(100));
    $this->drupalPost(NULL, $response, t('Send message'));
    $this->assertText(t('A message has been sent to @recipients.', array('@recipients' => $author->name)), t('Message sent confirmation displayed'));

    $this->drupalGet('messages/sent');
    $this->assertText($edit['subject'], t('Thread displayed in "Sent messages" for recipient.'));

    $this->drupalLogin($author);
    $this->drupalGet('messages');
    $this->assertText($edit['subject'], t('Thread displayed in inbox for author.'));

    // Test for bug http://drupal.org/node/617648
    // Delete all messages for author.
    $delete = array('list[1]' => 1);
    $this->drupalPost(NULL, $delete, t('Delete'));
    $this->assertNoText($edit['subject'], t('Thread has been deleted for author.'));

    // Write a reply as recipient.
    $this->drupalLogin($recipient);
    $this->drupalGet('messages');

    // Navigate to the new message.
    $this->clickLink($edit['subject']);
    $response = array('body[value]' => $this->randomName(100));
    $this->drupalPost(NULL, $response, t('Send message'));
    $this->assertText(t('A message has been sent to @recipients.', array('@recipients' => $author->name)), t('Message sent confirmation displayed'));

    // Check if thread is visible again for author.
    $this->drupalLogin($author);
    $this->drupalGet('messages');
    $this->assertText($edit['subject'], t('Thread displayed again in inbox for author.'));

    // Test archiving of messages.
    // Delete all messages for author.
    $archive = array(
      'list[1]' => 1,
      'operation' => 'archive',
    );
    $this->drupalPost(NULL, $archive, t('Execute'));
    $this->assertText(t('The messages have been archived.'), t('Confirmation message displayed'));
    $this->assertNoText($edit['subject'], t('Thread has been removed from inbox.'));

    $this->drupalGet('messages/list');
    $this->assertText($edit['subject'], t('Thread still displayed in "All messages" list.'));

  }
}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
PrivatemsgBaseTestCase::$profile protected property Use testing profile.
PrivatemsgFilterTestCase::getInfo public static function Implements getInfo().
PrivatemsgFilterTestCase::setUp function Implements setUp().
PrivatemsgFilterTestCase::testInboxSentHandling function Test correct handling of read all permissions.