### Eclipse Workspace Patch 1.0
#P simpletest
Index: tests/functional/blogapi.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/functional/blogapi.test,v
retrieving revision 1.10
diff -u -r1.10 blogapi.test
--- tests/functional/blogapi.test	5 Apr 2008 19:19:26 -0000	1.10
+++ tests/functional/blogapi.test	12 Apr 2008 22:37:51 -0000
@@ -2,31 +2,37 @@
 // $Id: blogapi.test,v 1.10 2008/04/05 19:19:26 boombatower Exp $
 
 class BlogAPITestCase extends DrupalTestCase {
+  /**
+   * Implementation of getInfo().
+   */
   function getInfo() {
     return array(
       'name' => t('BlogAPI functionality'),
       'description' => t('Create, edit, and delete post; upload file; and set/get categories.'),
-      'group' => t('Blog API Tests'),
+      'group' => t('BlogAPI Tests'),
     );
   }
 
+  /**
+   * Implementation of setUp().
+   */
   function setUp() {
     parent::setUp('blog', 'blogapi', 'taxonomy');
   }
 
+  /**
+   * Create, edit, and delete post; upload file; and set/get categories.
+   */
   function testBlogAPI() {
     // Create admin user and taxononmy for later use.
     $admin_user = $this->drupalCreateUser(array('administer taxonomy'));
     $this->drupalLogin($admin_user);
-
     $vid = $this->addVocabulary('simpletest_vocab');
-
     $term = $this->addTerm($vid, 'simpletest_term1');
-
-    $this->drupalGet('logout');
+    $this->drupalLogout();
 
     // Create user.
-    $web_user = $this->drupalCreateUser(array('create blog entries', 'delete own blog entries', 'edit own blog entries', 'administer content with blog api'));
+    $web_user = $this->drupalCreateUser(array('create blog content', 'delete own blog content', 'edit own blog content', 'administer content with blog api'));
     $this->drupalLogin($web_user);
 
     // Init common variables.
@@ -35,29 +41,27 @@
 
     // Get user's blog.
     $result = xmlrpc($local, 'blogger.getUsersBlogs', $appid, $web_user->name, $web_user->pass_raw);
-    $this->assertTrue($result, 'Request for user\'s blogs returned correctly.');
+    $this->assertTrue($result, t('Request for user\'s blogs returned correctly.'));
 
     if ($result !== FALSE) {
-      $this->assertTrue(array_key_exists('url', $result[0]), 'Blog found.');
-
-      if (array_key_exists('url', $result[0])) {
-        $blog_id = substr($result[0]['url'], strrpos($result[0]['url'], '/') + 1);
+      if ($this->assertTrue(array_key_exists('blogid', $result[0]), t('Blog found.'))) {
+        $blog_id = $result[0]['blogid'];
       }
     }
 
     // Create post.
-    $content = $this->randomName(10);
+    $content = $this->randomName(32);
     $result = xmlrpc($local, 'blogger.newPost', $appid, $blog_id, $web_user->name, $web_user->pass_raw, $content, TRUE);
-    $this->assertTrue($result, 'Post created.');
+    $this->assertTrue($result, t('Post created.'));
 
     $nid = $result;
 
     // Check recent posts.
     $result = xmlrpc($local, 'blogger.getRecentPosts', $appid, $blog_id, $web_user->name, $web_user->pass_raw, 5);
-    $this->assertTrue($result, 'Recent post list retreived.');
+    $this->assertTrue($result, t('Recent post list retreived.'));
 
     if ($result !== FALSE && array_key_exists('title', $result[0])) {
-      $this->assertEqual($content, $result[0]['title'], 'Post found.');
+      $this->assertEqual($content, $result[0]['title'], t('Post found.'));
     }
     else
       $this->assertTrue(false, 'Post found.');
@@ -65,61 +69,54 @@
     // Edit post.
     $content_new = $this->randomName(10);
     $result = xmlrpc($local, 'blogger.editPost', $appid, $nid, $web_user->name, $web_user->pass_raw, $content_new, TRUE);
-    $this->assertTrue($result, 'Post successfully modified.');
+    $this->assertTrue($result, t('Post successfully modified.'));
 
     // Upload file.
-    $file_contents = 'This is a test file that will be transfered via BlogAPI!';
+    $file = current($this->drupalGetTestFiles('text'));
+    $file_contents = file_get_contents($file->filename);
     $file = array();
     $file['name'] = $this->randomName() .'.txt';
     $file['type'] = 'text';
     $file['bits'] = xmlrpc_base64($file_contents);
     $result = xmlrpc($local, 'metaWeblog.newMediaObject', $blog_id, $web_user->name, $web_user->pass_raw, $file);
-    $this->assertTrue($result, 'File successfully uploaded.');
+    $this->assertTrue($result, t('File successfully uploaded.'));
 
     $url = (array_key_exists('url', $result) ? $result['url'] : '');
 
     // Check uploaded file.
     $this->drupalGet($url);
-    $this->assertEqual($this->drupalGetContent(), $file_contents, 'Uploaded contents verified.');
+    $this->assertEqual($this->drupalGetContent(), $file_contents, t('Uploaded contents verified.'));
 
     // Set post categories.
     $categories = array(array('categoryId' => $term));
     $result = xmlrpc($local, 'mt.setPostCategories', $nid, $web_user->name, $web_user->pass_raw, $categories);
-    $this->assertTrue($result, 'Post categories set.');
+    $this->assertTrue($result, t('Post categories set.'));
 
     // Get post categories.
     $result = xmlrpc($local, 'mt.getPostCategories', $nid, $web_user->name, $web_user->pass_raw);
-    $this->assertTrue($result, 'Category list successfully retreived.');
+    $this->assertTrue($result, t('Category list successfully retreived.'));
 
     if ($result !== FALSE && array_key_exists('categoryId', $result[0])) {
-      $this->assertEqual($term, $result[0]['categoryId'], 'Category list verified.');
+      $this->assertEqual($term, $result[0]['categoryId'], t('Category list verified.'));
     }
 
     // Delete post.
     $result = xmlrpc($local, 'blogger.deletePost', $appid, $nid, $web_user->name, $web_user->pass_raw, TRUE);
-    $this->assertTrue($result, 'Post successfully deleted.');
-
-    $this->drupalGet('logout');
-
-    // Remove taxonmy vocab.
-    $this->drupalLogin($admin_user);
-
-    $this->drupalPost('admin/content/taxonomy/edit/vocabulary/'. $vid, array(), t('Delete'));
-    $this->drupalPost(NULL, array(), t('Delete'));
-    $this->assertRaw(t('Deleted vocabulary %vocab.', array('%vocab' => 'simpletest_vocab')), 'Removed vocabulary.');
+    $this->assertTrue($result, t('Post successfully deleted.'));
   }
 
   /**
    * Add taxonomy vocabulary.
    *
    * @param string $vocab Vocabulary name.
+   * @return interger Vocab id.
    */
   function addVocabulary($vocab) {
     $edit = array();
     $edit['name'] = $vocab;
     $edit['nodes[blog]'] = TRUE;
     $this->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
-    $this->assertRaw(t('Created new vocabulary %vocab.', array('%vocab' => $edit['name'])), 'Taxonomy vocabulary added.');
+    $this->assertRaw(t('Created new vocabulary %vocab.', array('%vocab' => $edit['name'])), t('Taxonomy vocabulary added.'));
 
     $vocab_arr = taxonomy_get_vocabularies();
     $vid = NULL;
@@ -130,7 +127,7 @@
       }
     }
 
-    $this->assertNotNull($vid, 'Vocabulary found in database.');
+    $this->assertNotNull($vid, t('Vocabulary found in database.'));
     return $vid;
   }
 
@@ -139,12 +136,13 @@
    *
    * @param integer $vid Vocabulary id.
    * @param string $term Term name.
+   * @return interger Term id.
    */
   function addTerm($vid, $term) {
     $edit = array();
     $edit['name'] = $term;
     $this->drupalPost('admin/content/taxonomy/'. $vid .'/add/term', $edit, t('Save'));
-    $this->assertRaw(t('Created new term %term.', array('%term' => $edit['name'])), 'Taxonomy term added.');
+    $this->assertRaw(t('Created new term %term.', array('%term' => $edit['name'])), t('Taxonomy term added.'));
 
     $tree = taxonomy_get_tree($vid);
     $tid = NULL;
@@ -155,7 +153,7 @@
       }
     }
 
-    $this->assertNotNull($tid, 'Term found in database.');
+    $this->assertNotNull($tid, t('Term found in database.'));
     return $tid;
   }
 }
