You are here

public function BlogapiBloggerEndpointTestCase::testGetUsersBlogs in Blog API 7.2

Test blogger.getUsersBlogs().

Overrides BlogapiTestCase::testGetUsersBlogs

File

modules/blogapi_blogger/blogapi_blogger.test, line 30
Endpoint tests for BlogAPI Blogger

Class

BlogapiBloggerEndpointTestCase
@file Endpoint tests for BlogAPI Blogger

Code

public function testGetUsersBlogs() {

  // 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,
  ));
  $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.');
}