public function PrivatemsgServiceTestCase::testPrivatemsgServiceSend in Privatemsg 6.2
Test privatemsg.send service (create a new thread)
File
- privatemsg_service/
privatemsg_service.test, line 149 - Privatemsg Services test
Class
- PrivatemsgServiceTestCase
- Tests for services integration.
Code
public function testPrivatemsgServiceSend() {
// Setup 2 users.
$author_permissions = array(
'write privatemsg',
'administer services',
'access administration pages',
'send private messages from remote',
);
$author = $this
->drupalCreateUser($author_permissions);
$recipient = $this
->drupalCreateUser(array(
'read privatemsg',
));
// Have author navigate to services browser page for privatemsg.send and call the method.
$this
->drupalLogin($author);
$this
->drupalGet('admin/build/services/browse/privatemsg.send');
// Author sends a message to recipient through services.
$edit = array(
'arg[0]' => $recipient->name,
// Recipient name.
'arg[1]' => 'Message Subject',
// Message subject.
'arg[2]' => 'Body of this messages',
);
$this
->drupalPost('admin/build/services/browse/privatemsg.send', $edit, t('Call method'));
// Make sure the reply got sent out successfully.
$this
->assertRaw('<h3>Result</h3><code><pre>1</pre></code>', t('Messages was successfully sent to recipient.'));
}