class FeedAPIOPMLTestsCase in FeedAPI 6
Class for testing FeedAPI OPML support.
Hierarchy
- class \FeedAPIOPMLTestsCase extends \FeedAPITestCase
Expanded class hierarchy of FeedAPIOPMLTestsCase
File
- tests/
feedapi_opml.test, line 8
View source
class FeedAPIOPMLTestsCase extends FeedAPITestCase {
/**
* Implementation of getInfo().
*/
public static function getInfo() {
return array(
'name' => 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 = <<<EOT
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- OPML generated by UserLand Frontier v9.0 on Fri, 23 Jul 2004 23:41:33 GMT -->
<opml version="1.1">
\t<head>
\t\t<title>ourFavoriteFeedsData.top100</title>
\t\t<dateCreated>Fri, 02 Jan 2004 12:59:58 GMT</dateCreated>
\t\t<dateModified>Fri, 23 Jul 2004 23:41:32 GMT</dateModified>
\t\t<ownerName>Dave Winer</ownerName>
\t\t<ownerEmail>dave@userland.com</ownerEmail>
\t\t<expansionState></expansionState>
\t\t<vertScrollState>1</vertScrollState>
\t\t<windowTop>20</windowTop>
\t\t<windowLeft>0</windowLeft>
\t\t<windowBottom>120</windowBottom>
\t\t<windowRight>147</windowRight>
\t\t</head>
\t<body>
\t\t<outline title="Scripting News" count="580" xmlUrl="http://www.scripting.com/rss.xml"/>
\t\t<outline title="Wired News" count="546" xmlUrl="http://www.wired.com/news_drop/netcenter/netcenter.rdf"/>
\t\t</body>
\t</opml>
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);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedAPIOPMLTestsCase:: |
public static | function | Implementation of getInfo(). | |
FeedAPIOPMLTestsCase:: |
function | Checks if the OPML export page is basically sane. | ||
FeedAPIOPMLTestsCase:: |
function | Checks the OPML import form. |