### 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:24:10 -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. @@ -38,15 +44,13 @@ $this->assertTrue($result, '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]), '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.'); @@ -68,7 +72,8 @@ $this->assertTrue($result, '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'; @@ -99,20 +104,14 @@ $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->drupalLogout(); } /** * Add taxonomy vocabulary. * * @param string $vocab Vocabulary name. + * @return interger Vocab id. */ function addVocabulary($vocab) { $edit = array(); @@ -139,6 +138,7 @@ * * @param integer $vid Vocabulary id. * @param string $term Term name. + * @return interger Term id. */ function addTerm($vid, $term) { $edit = array();