public function FeedsWebTestCase::createFeedNode in Feeds 6
Same name and namespace in other branches
- 7.2 tests/feeds.test \FeedsWebTestCase::createFeedNode()
- 7 tests/feeds.test.inc \FeedsWebTestCase::createFeedNode()
Create a test feed node. Test user has to have sufficient permissions:
- create [type] content
- use feeds
Assumes that page content type has been configured with createImporterConfiguration() as a feed content type.
Return value
The node id of the node created.
13 calls to FeedsWebTestCase::createFeedNode()
- FeedsExamplesFastFeedTestCase::test in feeds_fast_news/
feeds_fast_news.test - Run tests.
- FeedsExamplesFeedTestCase::test in feeds_news/
feeds_news.test - Run tests.
- FeedsMapperFileFieldTestCase::test in tests/
feeds_mapper_filefield.test - Basic test loading a single entry CSV file.
- FeedsMapperLinkTestCase::test in tests/
feeds_mapper_link.test - Basic test loading a single entry CSV file.
- FeedsMapperLocaleTestCase::testInheritLanguage in tests/
feeds_mapper_locale.test - Test inheriting language from the feed node.
File
- tests/
feeds.test, line 187 - Common functionality for all Feeds tests.
Class
- FeedsWebTestCase
- Test basic Data API functionality.
Code
public function createFeedNode($id = 'syndication', $feed_url = NULL, $title = '', $content_type = NULL) {
if (empty($feed_url)) {
$feed_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2';
}
// If content type not given, retrieve it.
if (!$content_type) {
$result = db_query("SELECT config FROM {feeds_importer} WHERE id = '%s'", $id);
$config = unserialize(db_result($result));
$content_type = $config['content_type'];
$this
->assertFalse(empty($content_type), 'Valid content type found: ' . $content_type);
}
// Create a feed node.
$edit = array(
'title' => $title,
'feeds[FeedsHTTPFetcher][source]' => $feed_url,
);
$this
->drupalPost('node/add/' . str_replace('_', '-', $content_type), $edit, 'Save');
$this
->assertText('has been created.');
// Get the node id from URL.
$nid = $this
->getNid($this
->getUrl());
// Check whether feed got recorded in feeds_source table.
$result = db_result(db_query("SELECT COUNT(*) FROM {feeds_source} WHERE id = '%s' AND feed_nid = %d", $id, $nid));
$this
->assertEqual(1, $result);
$source = db_fetch_object(db_query("SELECT * FROM {feeds_source} WHERE id = '%s' AND feed_nid = %d", $id, $nid));
$config = unserialize($source->config);
$this
->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
return $nid;
}