function PrivatemsgLimitsTestCase::testReceiveLimitsThreads in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg_limits/privatemsg_limits.test \PrivatemsgLimitsTestCase::testReceiveLimitsThreads()
- 7.2 privatemsg_limits/privatemsg_limits.test \PrivatemsgLimitsTestCase::testReceiveLimitsThreads()
Test receive limit with messages as limits object.
File
- privatemsg_limits/
privatemsg_limits.test, line 264 - This file contains tests for the privatemsg limits module
Class
- PrivatemsgLimitsTestCase
- Test cases for the privatemsg_limits module.
Code
function testReceiveLimitsThreads() {
$admin = $this
->drupalCreateUser(array(
'administer privatemsg settings',
'write privatemsg',
'read privatemsg',
));
$user = $this
->drupalCreateUser(array(
'write privatemsg',
'read privatemsg',
));
$this
->drupalLogin($admin);
$settings = array(
'privatemsg_limits_receive_enabled' => TRUE,
'privatemsg_limits_receive_amount' => 3,
'privatemsg_limits_receive_amount_role_3' => 5,
'privatemsg_limits_receive_object' => 'thread',
);
$this
->drupalPost('admin/config/messaging/privatemsg/limits', $settings, t('Save configuration'));
// Check empty inbox.
$this
->drupalGet('messages');
$this
->assertText(t('You are currently using @percent% (@used conversations) of your @limit conversations limit.', array(
'@percent' => 0,
'@used' => 0,
'@limit' => 5,
)));
$this
->drupalLogin($user);
$this
->drupalGet('messages');
$this
->assertText(t('You are currently using @percent% (@used conversations) of your @limit conversations limit.', array(
'@percent' => 0,
'@used' => 0,
'@limit' => 3,
)));
// Send three messages from user to admin.
for ($i = 0; $i < 3; $i++) {
$edit = array(
'recipient' => $admin->name,
'subject' => $this
->randomName(20),
'body[value]' => $this
->randomName(100),
);
$this
->drupalPost('messages/new', $edit, t('Send message'));
$this
->assertText(t('A message has been sent to @recipients.', array(
'@recipients' => $admin->name,
)));
}
// Try sending an additional message.
$blocked = array(
'recipient' => $admin->name,
'subject' => $this
->randomName(20),
'body[value]' => $this
->randomName(100),
);
$this
->drupalPost('messages/new', $blocked, t('Send message'));
$this
->assertText(t("Your message mailbox is currently full. You are allowed a maximum of @limit conversations in your mailbox at one time. You won't be able to start or receive new conversations until you delete some existing ones.", array(
'@limit' => 3,
)), 'Limit exceeded message displayed.');
// Try to reply to a sent message.
$this
->drupalGet('messages/sent');
$this
->clickLink($edit['subject']);
$reply = array(
'body[value]' => $this
->randomName(100),
);
$this
->drupalPost(NULL, $reply, t('Send message'));
$this
->assertText(t('A message has been sent to @recipients.', array(
'@recipients' => $admin->name,
)));
// Check user limits.
$this
->drupalGet('messages');
$this
->assertText(t('You are currently using @percent% (@used conversations) of your @limit conversations limit.', array(
'@percent' => 100,
'@used' => 3,
'@limit' => 3,
)));
// Check admin limits.
$this
->drupalLogin($admin);
$this
->drupalGet('messages');
$this
->assertText(t('You are currently using @percent% (@used conversations) of your @limit conversations limit.', array(
'@percent' => 60,
'@used' => 3,
'@limit' => 5,
)));
// Try to send a message to the user.
$blocked = array(
'recipient' => $user->name,
'subject' => $this
->randomName(20),
'body[value]' => $this
->randomName(100),
);
$this
->drupalPost('messages/new', $blocked, t('Send message'));
$this
->assertText(t("This message cannot be sent to @user because @user's mailbox is full.", array(
'@user' => $user->name,
)));
// Try to reply to a message.
$this
->drupalGet('messages');
$this
->clickLink($edit['subject']);
$reply = array(
'body[value]' => $this
->randomName(100),
);
$this
->drupalPost(NULL, $reply, t('Send message'));
$this
->assertText(t('A message has been sent to @recipients.', array(
'@recipients' => $user->name,
)));
}