? feedapi_comments.test.patch
Index: tests/feedapi_comments.test
===================================================================
RCS file: tests/feedapi_comments.test
diff -N tests/feedapi_comments.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/feedapi_comments.test	2 Nov 2008 06:42:56 -0000
@@ -0,0 +1,74 @@
+<?php
+// $Id$
+
+/**
+ * Test comment aggregation and supported sites.
+ */
+
+class FeedAPICommentsTestCase extends DrupalWebTestCase {
+  
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => 'FeedAPI Comments', 
+      'description' => 'Tests comment aggregation and supported sites.', 
+      'group' => 'FeedAPI comments');
+  }
+  
+  function setUp() {
+    parent::setUp('feedapi', 'feedapi_comments', 'parser_comments', 'parser_common_syndication');
+  }
+  
+  function testComments() {
+    
+    // 1) Create and login admin user
+    $admin_user = $this->drupalCreateUser(array('administer content types', 'administer feedapi', 'administer permissions', 'administer users', 'access administration pages'));
+    $this->drupalLogin($admin_user);
+    
+    // 2) Create and configure content type
+    $this->_createFeedContentType('Comment feed', 'feed_comment');
+    
+    // 3) Create and login non admin user
+    // What's going wrong here? Why can I not create a user with create feed_comment content permissions?
+    // node_get_types('types', NULL, TRUE); (Cached node types is not the cause)
+    // $test_user = $this->drupalCreateUser(array('create feed_comment content'));
+    // Creating user with administer nodes permissins instead.
+    $test_user = $this->drupalCreateUser(array('administer nodes'));
+    $this->drupalLogin($test_user);
+    
+    // 4) Test supported sites.
+    // @todo: Get more stable addresses.
+    $this->_createFeed('feed_comment', 'http://www.youtube.com/watch?v=QB46rT2Nz1E&feature=rec-fresh', 'Rahzel Iron Man', array('OH SHIT THAT WAS TIGHT!'));
+    $this->_createFeed('feed_comment', 'http://www.flickr.com/photos/a-barth/2837477466/in/set-72157607163515598/', 'Ali', array('i love how your wide angle lens exaggerates'));
+    $this->_createFeed('feed_comment', 'http://www.vimeo.com/2040753', 'School project', array('this kinda sounds like fringe just THOUSAND TIMES BETTER!'));
+    
+  }
+  
+  function _createFeedContentType($name, $type) {
+    // Create content type - as user through form.
+    $edit = array();
+    $edit['name'] = $name;
+    $edit['type'] = $type;
+    $edit['feedapi[enabled]'] = '1';
+    $edit['feedapi[refresh_on_create]'] = '1';
+    $edit['feedapi[parsers][parser_comments][enabled]'] = '1';
+    $edit['feedapi[processors][feedapi_comments][enabled]'] = '1';
+    $this->drupalPost('admin/content/types/add', $edit, t('Save content type'));
+    // Confirm that the box has been created.
+    $this->assertText(t('The content type !name has been added.', array('!name' => $name)), t('Content type successfully created.'));
+  }
+  
+  function _createFeed($type, $url, $test_title, $test_strings) {
+    $edit = array();
+    $edit['feedapi[feedapi_url]'] = $url;
+    $this->drupalPost('node/add/'. str_replace('_', '-', $type), $edit, t('Save'));
+    $this->assertText('has been created');
+    // Title is not yet supported.
+    // $this->assertText($test_title);
+    foreach ($test_strings as $test_string) {
+      $this->assertText($test_string);
+    }
+  }
+}
\ No newline at end of file
