function PrivatemsgTagsTestCase::testOnlyTaggingPermission in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg_filter/privatemsg_filter.test \PrivatemsgTagsTestCase::testOnlyTaggingPermission()
- 7.2 privatemsg_filter/privatemsg_filter.test \PrivatemsgTagsTestCase::testOnlyTaggingPermission()
Tests if the tagging feature works when a user doesn't have the filter permission.
File
- privatemsg_filter/
privatemsg_filter.test, line 289 - Contains tests for the privatemsg_filter module.
Class
- PrivatemsgTagsTestCase
- Test filters, tags and inbox/sent handling.
Code
function testOnlyTaggingPermission() {
$admin = $this
->drupalCreateUser(array(
'administer privatemsg settings',
'write privatemsg',
'read privatemsg',
));
$webuser = $this
->drupalCreateUser(array(
'write privatemsg',
'read privatemsg',
'tag private messages',
'create private message tags',
));
// Display tag column in thread list.
$this
->drupalLogin($admin);
$this
->drupalPost('admin/config/messaging/privatemsg', array(
'privatemsg_display_fields[tags]' => 'tags',
), t('Save configuration'));
// Create two threads through the API.
$response = privatemsg_new_thread(array(
$webuser,
), $subject1 = $this
->randomName(10), $this
->randomName(20), array(
'author' => $admin,
));
$thread_id1 = $response['message']->thread_id;
$response = privatemsg_new_thread(array(
$webuser,
), $subject2 = $this
->randomName(10), $this
->randomName(20), array(
'author' => $admin,
));
$thread_id2 = $response['message']->thread_id;
// Log in and check that both messages are visible.
$this
->drupalLogin($webuser);
$this
->drupalGet('messages');
$this
->assertText($subject1, t('Message is displayed.'));
$this
->assertText($subject2, t('Message is displayed.'));
// Tag first thread.
$tag = array(
'tag-add' => $this
->randomName(5),
'list[' . $thread_id1 . ']' => $thread_id1,
);
$this
->drupalPost(NULL, $tag, t('Apply Tag'));
// Filter by tag, verify that only the first thread is displayed, an
// informal message and no filter form.
$this
->clickLink($tag['tag-add']);
$this
->assertText(t('Messages tagged with @tags are currently displayed. Click here to remove this filter.', array(
'@tags' => $tag['tag-add'],
)), t('Tag filter message displayed.'));
$this
->assertNoText(t('Filter messages'));
$this
->assertText($subject1, t('First thread displayed.'));
$this
->assertNoText($subject2, t('Second thread not displayed.'));
// Check paging, set threads per page to 1.
variable_set('privatemsg_per_page', 1);
// Go the second page, only the second thread should be visible there.
$this
->drupalGet('messages');
$this
->clickLink('2');
$this
->assertNoText($subject1, t('First thread not displayed.'));
$this
->assertText($subject2, t('Second thread displayed.'));
// Only the first thread should be visible on the
// first page.
$this
->clickLink('1');
$this
->assertText($subject1, t('First thread displayed.'));
$this
->assertNoText($subject2, t('Second thread not displayed.'));
// Now, filter by tag (which should be visible on this page) and verify
// that there is no pager shown.
$this
->clickLink($tag['tag-add']);
$this
->assertText(t('Messages tagged with @tags are currently displayed. Click here to remove this filter.', array(
'@tags' => $tag['tag-add'],
)), t('Tag filter message displayed.'));
$this
->assertNoText(t('Filter messages'));
$this
->assertText($subject1, t('First thread displayed.'));
$this
->assertNoText($subject2, t('Second thread not displayed.'));
$this
->assertNoLink('2');
}