public function FeedsWebTestBase::createFeedNode in Feeds 8.2
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.
9 calls to FeedsWebTestBase::createFeedNode()
- FeedsMapperFileTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperFileTest.php - Basic test loading a single entry CSV file.
- FeedsMapperLinkTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperLinkTest.php - Basic test loading a single entry CSV file.
- FeedsMapperTaxonomyTest::testInheritTaxonomy in lib/
Drupal/ feeds/ Tests/ FeedsMapperTaxonomyTest.php - Tests inheriting taxonomy from the feed node.
- FeedsMapperTaxonomyTest::testSearchByName in lib/
Drupal/ feeds/ Tests/ FeedsMapperTaxonomyTest.php - Tests searching taxonomy terms by name.
- FeedsRSStoNodesTest::test in lib/
Drupal/ feeds/ Tests/ FeedsRSStoNodesTest.php - Test node creation, refreshing/deleting feeds and feed items.
File
- lib/
Drupal/ feeds/ Tests/ FeedsWebTestBase.php, line 244 - Common functionality for all Feeds tests.
Class
- FeedsWebTestBase
- Test basic Data API functionality.
Namespace
Drupal\feeds\TestsCode
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) {
$config = config('feeds.importer.' . $id)
->get('config');
$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[Drupal\\feeds\\Plugin\\feeds\\fetcher\\FeedsHTTPFetcher][source]' => $feed_url,
);
$this
->drupalPost('node/add/' . str_replace('_', '-', $content_type), $edit, 'Save and publish');
$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.
$query = db_select('feeds_source', 's')
->condition('s.id', $id, '=')
->condition('s.feed_nid', $nid, '=');
$query
->addExpression("COUNT(*)");
$result = $query
->execute()
->fetchField();
$this
->assertEqual(1, $result);
$source = db_select('feeds_source', 's')
->condition('s.id', $id, '=')
->condition('s.feed_nid', $nid, '=')
->fields('s', array(
'config',
))
->execute()
->fetchObject();
$config = unserialize($source->config);
$this
->assertEqual($config['Drupal\\feeds\\Plugin\\feeds\\fetcher\\FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
return $nid;
}