public function BlogapiTestCase::testGetUsersBlogs in Blog API 7.2
Test main validation functions via blogger.getUsersBlogs().
1 method overrides BlogapiTestCase::testGetUsersBlogs()
- BlogapiBloggerEndpointTestCase::testGetUsersBlogs in modules/
blogapi_blogger/ blogapi_blogger.test - Test blogger.getUsersBlogs().
File
- ./
blogapi.test, line 63 - Test for general BlogAPI functionality
Class
- BlogapiTestCase
- @file Test for general BlogAPI functionality
Code
public function testGetUsersBlogs() {
// Test invalid params
$result = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(),
));
$this
->assertTrue(strpos(xmlrpc_error_msg(), 'Missing required argument') !== FALSE, 'Needs corect arguments');
// Test authantication with wrong username/password
$blog_types = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(
'1234567890',
$this
->randomName(),
$this
->randomString(),
),
));
$this
->assertEqual(xmlrpc_error_msg(), 'Invalid username or password', 'Access only for logged in users');
// Test user without blogAPI permission.
$blog_types = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(
'1234567890',
$this->unPrivilegedUser->name,
$this->unPrivilegedUser->pass_raw,
),
));
$this
->assertEqual(xmlrpc_error_msg(), 'You do not have permission to edit this blog', 'User must have blogAPI permissions');
// Restrict all content types, because article is allowed by default
variable_set('blogapi_node_types', array());
// Test blog type retrieval before creating and configuring node types.
$blog_types = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(
'1234567890',
$this->privilegedUser->name,
$this->privilegedUser->pass_raw,
),
));
$this
->assertEqual(count($blog_types), 0, 'No blog types exist and none were returned');
// Create a content type and re-test. No types should be returned
// because the content type is not configured for use with BlogAPI.
$type = $this
->drupalCreateContentType();
$blog_types = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(
'1234567890',
$this->privilegedUser->name,
$this->privilegedUser->pass_raw,
),
));
$this
->assertEqual(count($blog_types), 0, 'No blog types are configured and none were returned');
// Add the new content type to the blog list and make sure that it's
// returned correctly.
variable_set('blogapi_node_types', array(
$type->type,
));
// Test valid process
$blog_types = xmlrpc($this->xmlrpcUrl, array(
'blogger.getUsersBlogs' => array(
'1234567890',
$this->privilegedUser->name,
$this->privilegedUser->pass_raw,
),
));
$this
->assertEqual(count($blog_types), 1, 'One blog type is configured and one was returned');
$this
->assertEqual($blog_types[0]['blogid'], $type->type, 'The configured blog type is the one that was returned');
$this
->assertEqual($blog_types[0]['blogName'], $this->privilegedUser->name . ': ' . $type->name, 'The blogName is returned correctly.');
}