public function BlogapiBloggerEndpointTestCase::testGetPost in Blog API 7.2
Test blogger.getPost().
File
- modules/
blogapi_blogger/ blogapi_blogger.test, line 251 - Endpoint tests for BlogAPI Blogger
Class
- BlogapiBloggerEndpointTestCase
- @file Endpoint tests for BlogAPI Blogger
Code
public function testGetPost() {
$type = $this
->drupalCreateContentType();
// Allow to user our content type with BlogAPI
variable_set('blogapi_node_types', array(
$type->type,
));
$node = $this
->drupalCreateNode(array(
'type' => $type->type,
'uid' => $this->privilegedUser2->uid,
));
// Test user without node view permission.
$result = xmlrpc($this->xmlrpcUrl, array(
'blogger.getPost' => array(
'1234567890',
$node->nid,
$this->privilegedUser->name,
$this->privilegedUser->pass_raw,
),
));
$this
->assertEqual(xmlrpc_error_msg(), format_string('You are not authorized to view post @postid', array(
'@postid' => $node->nid,
)), 'User must node view permissions');
// Normal test
$result = xmlrpc($this->xmlrpcUrl, array(
'blogger.getPost' => array(
'1234567890',
$node->nid,
$this->privilegedUser2->name,
$this->privilegedUser2->pass_raw,
),
));
$this
->assertTrue($result['userid'] == $this->privilegedUser2->name, 'Author name is correct');
$this
->assertTrue($result['dateCreated'] == xmlrpc_date($node->created), 'Created date is correct');
$this
->assertTrue($result['title'] == $node->title, 'Post title is correct');
$this
->assertTrue($result['postid'] == $node->nid, 'Post ID is correct');
$node_body = !empty($node->body[LANGUAGE_NONE][0]['value']) ? $node->body[LANGUAGE_NONE][0]['value'] : '';
$this
->assertTrue($result['content'] == '<title>' . $node->title . '</title>' . $node_body, 'Post content is correct');
$this
->assertTrue($result['link'] == url('node/' . $node->nid, array(
'absolute' => TRUE,
)), 'Post link is correct');
}