t('FeedAPI OPML support'), 'description' => t('Tests both OPML import and export functionality.'), 'group' => t('FeedAPI'), ); } /** * Checks if the OPML export page is basically sane. */ function testFeedAPI_Node_Export_OPML() { $parsers_ok = $this->get_parsers(); // Create a new content-type for creating the feed node $this->create_type(array_pop($parsers_ok)); $this->feedapi_user(); $this->drupalGet('admin/content/feed/export_opml'); $this->assertResponse(200, 'The export OPML path returns good status code.'); } /** * Checks the OPML import form. */ function testFeedAPI_Node_Import_Form() { $opml = << ourFavoriteFeedsData.top100 Fri, 02 Jan 2004 12:59:58 GMT Fri, 23 Jul 2004 23:41:32 GMT Dave Winer dave@userland.com 1 20 0 120 147 EOT; $parsers = $this->get_parsers(); foreach ($parsers as $parser) { $this->create_type($parser); $this->feedapi_user(); $this->drupalGet('admin/content/feed/import_opml'); $this->assertResponse(200, 'The OPML import form is accessible.'); $this->assertText(t('OPML File'), 'The retrieved page contains the OPML form.'); $this->drupalPost('admin/content/feed/import_opml', array(), 'Import'); $this->assertText(t('Data could not be retrieved, invalid or empty file.'), 'The error message appears when the empty OPML import form is submitted.'); $opml_filename = file_directory_temp() .'/'. md5($opml); file_put_contents($opml_filename, $opml); $edit['files[opml]'] = $opml_filename; $edit['feed_type'] = $this->info->type; $edit['override_title'] = TRUE; $edit['override_body'] = FALSE; $this->drupalPost('admin/content/feed/import_opml', $edit, 'Import'); $nid = db_result(db_query("SELECT n.nid FROM {node} n LEFT JOIN {feedapi} f ON n.nid = f.nid WHERE f.url = '%s' ORDER BY nid DESC", 'http://www.scripting.com/rss.xml')); $node = node_load($nid); $this->assertTrue(is_object($node), 'The first entry of OPML can be loaded as a node.'); node_delete($nid); unlink($opml_filename); } } }