You are here

function PrivatemsgTagsTestCase::testFilterFormSingleThread in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 privatemsg_filter/privatemsg_filter.test \PrivatemsgTagsTestCase::testFilterFormSingleThread()
  2. 7.2 privatemsg_filter/privatemsg_filter.test \PrivatemsgTagsTestCase::testFilterFormSingleThread()

Create and update tags on a single thread.

File

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

Class

PrivatemsgTagsTestCase
Test filters, tags and inbox/sent handling.

Code

function testFilterFormSingleThread() {
  $webuser = $this
    ->drupalCreateuser(array(
    'read privatemsg',
    'write privatemsg',
    'tag private messages',
    'create private message tags',
  ));

  // Create a new thread through the api.
  $response = privatemsg_new_thread(array(
    $webuser,
  ), $this
    ->randomName(10), $this
    ->randomName(20), array(
    'author' => $webuser,
  ));
  $thread_id = $response['message']->thread_id;
  $tags = array(
    $this
      ->randomName(),
    $this
      ->randomName(),
    $this
      ->randomName(),
    $this
      ->randomName(),
  );
  $edit = array(
    'tags' => $tags[0] . ', ' . $tags[1],
  );
  $this
    ->drupalLogin($webuser);
  $this
    ->drupalGet('messages/view/' . $thread_id);
  $this
    ->clickLink(t('Tag this conversation'));
  $this
    ->drupalPost(NULL, $edit, t('Tag this conversation'));
  $this
    ->assertText($tags[0], t('Found message tag'));
  $this
    ->assertText($tags[1], t('Found message tag'));

  // Create a another thread through the api.
  $response = privatemsg_new_thread(array(
    $webuser,
  ), $this
    ->randomName(10), $this
    ->randomName(20), array(
    'author' => $webuser,
  ));
  $thread_id = $response['message']->thread_id;
  $edit = array(
    'tags' => $tags[1] . ', ' . $tags[2],
  );
  $this
    ->drupalGet('messages/view/' . $thread_id);
  $this
    ->clickLink(t('Tag this conversation'));
  $this
    ->drupalPost(NULL, $edit, t('Tag this conversation'));
  $this
    ->assertText($tags[1], t('Found message tag'));
  $this
    ->assertText($tags[2], t('Found message tag'));

  // Change tags.
  $edit = array(
    'tags' => $tags[0],
  );
  $this
    ->drupalGet('messages/view/' . $thread_id);
  $this
    ->clickLink(t('(modify tags)'));
  $this
    ->drupalPost(NULL, $edit, t('Tag this conversation'));
  $this
    ->assertText($tags[0], t('Found message tag'));
  $this
    ->assertNoText($tags[1], t('Tag has been removed.'));
  $this
    ->assertNoText($tags[2], t('Tag has been removed.'));
}