Skip to content
Snippets Groups Projects
Commit 7f33f0c4 authored by Alex Barth's avatar Alex Barth
Browse files

#851194: Featurize. Replace feeds_defaults with feeds_fast_news, feeds_import,...

#851194: Featurize. Replace feeds_defaults with feeds_fast_news, feeds_import, feeds_news. Needs more testing especially of upgrade path.
parent e0d367bd
No related branches found
No related tags found
No related merge requests found
Showing
with 1056 additions and 43 deletions
...@@ -492,3 +492,24 @@ function feeds_update_6009() { ...@@ -492,3 +492,24 @@ function feeds_update_6009() {
db_create_table($ret, 'feeds_push_subscriptions', $table); db_create_table($ret, 'feeds_push_subscriptions', $table);
return $ret; return $ret;
} }
/**
* Enable all Feeds News, Feeds Import and Feeds fast news features.
*/
function feeds_update_6010() {
drupal_install_modules(array('feeds_news', 'feeds_import'));
if (module_exist('data')) {
drupal_install_modules(array('feeds_fast_news'));
drupal_set_message(t('Installed Feeds News, Feeds Fast News and Feeds Import as replacement for Feeds Defaults module.'));
}
else {
drupal_set_message(t('Installed Feeds News and Feeds Import as replacement for Feeds Defaults module.'));
}
if (module_exists('features')) {
drupal_set_message(t('Review importer configurations on admin/build/feeds and disable Feeds Features on admin/build/features if undesired configurations show up.'));
}
else {
drupal_set_message(t('Review importer configurations on admin/build/feeds and disable Feeds Feature modules on admin/build/modules if undesired configurations show up.'));
}
return array();
}
<?php
// $Id$
/**
* @file
* Default hook definitions. This code is generated with Features module but it
* has been tweaked manually. Do not attempt to reexport.
*/
/**
* Implementation of hook_ctools_plugin_api().
*/
function feeds_defaults_ctools_plugin_api() {
module_load_include('inc', 'feeds_defaults', 'feeds_defaults.defaults');
$args = func_get_args();
return call_user_func_array('_feeds_defaults_ctools_plugin_api', $args);
}
/**
* Implementation of hook_data_default().
*/
function feeds_defaults_data_default() {
module_load_include('inc', 'feeds_defaults', 'feeds_defaults.defaults');
$args = func_get_args();
return call_user_func_array('_feeds_defaults_data_default', $args);
}
/**
* Implementation of hook_feeds_importer_default().
*/
function feeds_defaults_feeds_importer_default() {
module_load_include('inc', 'feeds_defaults', 'feeds_defaults.defaults');
$args = func_get_args();
return call_user_func_array('_feeds_defaults_feeds_importer_default', $args);
}
; $Id$
core = "6.x"
name = "Feeds Defaults"
package = "Feeds"
description = "Get started: useful default configurations for Feeds: RSS/Atom aggregation, OPML import, node import and user import."
project = "Feeds"
dependencies[] = "feeds"
php = 5.2
<?php <?php
// $Id$
/** /**
* @file * Implementation of hook_data_default().
* Actual function bodies for default hook definitions in
* feeds_defaults.features.inc.
*/ */
function feeds_fast_news_data_default() {
/**
* Helper to implementation of hook_ctools_plugin_api().
*/
function _feeds_defaults_ctools_plugin_api() {
$args = func_get_args();
$module = array_shift($args);
$api = array_shift($args);
if ($module == "data" && $api == "data_default") {
return array("version" => 1);
}
else if ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => 1);
}
}
/**
* Helper to implementation of hook_data_default().
*/
function _feeds_defaults_data_default() {
$export = array(); $export = array();
$data_table = new stdClass; $data_table = new stdClass;
$data_table->disabled = FALSE; /* Edit this to true to make a default data_table disabled initially */ $data_table->disabled = FALSE; /* Edit this to true to make a default data_table disabled initially */
...@@ -153,278 +131,3 @@ function _feeds_defaults_data_default() { ...@@ -153,278 +131,3 @@ function _feeds_defaults_data_default() {
$export['feeds_data_feed_fast'] = $data_table; $export['feeds_data_feed_fast'] = $data_table;
return $export; return $export;
} }
/**
* Helper to implementation of hook_feeds_importer_default().
*/
function _feeds_defaults_feeds_importer_default() {
$export = array();
$feeds_importer = new stdClass;
$feeds_importer->disabled = TRUE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed';
$feeds_importer->config = array(
'name' => 'Feed',
'description' => 'Import RSS or Atom feeds, create nodes from feed items.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'feed_item',
'update_existing' => 0,
'expire' => '-1',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'description',
'target' => 'body',
'unique' => FALSE,
),
'2' => array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
'3' => array(
'source' => 'url',
'target' => 'url',
'unique' => TRUE,
),
'4' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
),
),
),
'content_type' => 'feed',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['feed'] = $feeds_importer;
// Expose a default configuration for Data if enabled.
if (module_exists('data')) {
$feeds_importer = new stdClass;
$feeds_importer->disabled = TRUE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed_fast';
$feeds_importer->config = array(
'name' => 'Fast feed',
'description' => 'Create light weight database records from feed items. Faster than aggregating nodes.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsDataProcessor',
'config' => array(
'update_existing' => 0,
'expire' => '7257600',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => 0,
),
'1' => array(
'source' => 'description',
'target' => 'description',
'unique' => 0,
),
'2' => array(
'source' => 'url',
'target' => 'url',
'unique' => 1,
),
'3' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => 1,
),
),
),
),
'content_type' => 'feed_fast',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['feed_fast'] = $feeds_importer;
}
$feeds_importer = new stdClass;
$feeds_importer->disabled = TRUE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'node';
$feeds_importer->config = array(
'name' => 'Node import',
'description' => 'Import nodes from CSV file.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ',',
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'story',
'update_existing' => 1,
'expire' => '-1',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'body',
'target' => 'body',
'unique' => FALSE,
),
'2' => array(
'source' => 'published',
'target' => 'created',
'unique' => FALSE,
),
'3' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => 1,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['node'] = $feeds_importer;
$feeds_importer = new stdClass;
$feeds_importer->disabled = TRUE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'opml';
$feeds_importer->config = array(
'name' => 'OPML import',
'description' => 'Import subscriptions from OPML files. Use together with "Feed" configuration.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(),
),
'parser' => array(
'plugin_key' => 'FeedsOPMLParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsFeedNodeProcessor',
'config' => array(
'content_type' => 'feed',
'update_existing' => 0,
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'xmlurl',
'target' => 'source',
'unique' => 1,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['opml'] = $feeds_importer;
$feeds_importer = new stdClass;
$feeds_importer->disabled = TRUE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'user';
$feeds_importer->config = array(
'name' => 'User import',
'description' => 'Import users from CSV file.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ',',
),
),
'processor' => array(
'plugin_key' => 'FeedsUserProcessor',
'config' => array(
'roles' => array(),
'update_existing' => FALSE,
'status' => 1,
'mappings' => array(
'0' => array(
'source' => 'name',
'target' => 'name',
'unique' => 0,
),
'1' => array(
'source' => 'mail',
'target' => 'mail',
'unique' => 1,
),
'2' => array(
'source' => 'created',
'target' => 'created',
'unique' => FALSE,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['user'] = $feeds_importer;
return $export;
}
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function feeds_fast_news_ctools_plugin_api() {
list($module, $api) = func_get_args();
if ($module == "data" && $api == "data_default") {
return array("version" => 1);
}
elseif ($module == "data" && $api == "data_table") {
return array("version" => 1);
}
elseif ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => 1);
}
}
/**
* Implementation of hook_node_info().
*/
function feeds_fast_news_node_info() {
$items = array(
'feed_fast' => array(
'name' => t('Fast feed'),
'module' => 'node',
'description' => t('Subscribe to RSS or Atom feeds. Create light weight database records from feed content.'),
'has_title' => '1',
'title_label' => t('Title'),
'has_body' => '1',
'body_label' => t('Body'),
'min_word_count' => '0',
'help' => '',
),
);
return $items;
}
<?php
/**
* Implementation of hook_feeds_importer_default().
*/
function feeds_fast_news_feeds_importer_default() {
$export = array();
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed_fast';
$feeds_importer->config = array(
'name' => 'Fast feed',
'description' => 'Create light weight database records from feed items. Faster than aggregating nodes.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsDataProcessor',
'config' => array(
'update_existing' => 0,
'expire' => '7257600',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => 0,
),
'1' => array(
'source' => 'description',
'target' => 'description',
'unique' => 0,
),
'2' => array(
'source' => 'url',
'target' => 'url',
'unique' => 1,
),
'3' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => 1,
),
),
),
),
'content_type' => 'feed_fast',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['feed_fast'] = $feeds_importer;
return $export;
}
core = "6.x"
dependencies[] = "data"
dependencies[] = "feeds"
description = "A fast news aggregator built with feeds, creates flat database records from imported feed items."
features[ctools][] = "data:data_default:1"
features[ctools][] = "data:data_table:1"
features[ctools][] = "feeds:feeds_importer_default:1"
features[data_tables][] = "feeds_data_feed_fast"
features[feeds_importer][] = "feed_fast"
features[node][] = "feed_fast"
name = "Feeds Fast News"
package = "Feeds"
project = "Feeds"
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
/** /**
* Implementation of hook_schema(). * Implementation of hook_schema().
*/ */
function feeds_defaults_schema() { function feeds_fast_news_schema() {
// Install data tables. // Install data tables.
include_once('feeds_defaults.features.inc'); include_once('feeds_fast_news.data_default.inc');
$tables = feeds_defaults_data_default(); $tables = feeds_fast_news_data_default();
$schema = array(); $schema = array();
foreach ($tables as $name => $table) { foreach ($tables as $name => $table) {
$schema[$name] = $table->table_schema; $schema[$name] = $table->table_schema;
...@@ -23,13 +23,24 @@ function feeds_defaults_schema() { ...@@ -23,13 +23,24 @@ function feeds_defaults_schema() {
/** /**
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
function feeds_defaults_install() { function feeds_fast_news_install() {
drupal_install_schema('feeds_defaults'); // We are replacing feeds_defaults module, taking over its table.
// Hence we cannot use drupal_install_schema('feeds_fast_news');
$schema = drupal_get_schema_unprocessed('feeds_fast_news');
_drupal_initialize_schema('feeds_fast_news', $schema);
$ret = array();
foreach ($schema as $name => $table) {
// Check whether table exists.
if (!db_table_exists($name)) {
db_create_table($ret, $name, $table);
}
}
} }
/** /**
* Implementation of hook_uninstall(); * Implementation of hook_uninstall();
*/ */
function feeds_defaults_uninstall() { function feeds_defaults_uninstall() {
drupal_uninstall_schema('feeds_defaults'); drupal_uninstall_schema('feeds_fast_news');
} }
<?php
include_once('feeds_fast_news.features.inc');
<?php
// $Id$
/**
* @file
* Tests for feeds_fast_news feature.
*/
// Require FeedsWebTestCase class definition.
require_once(dirname(__FILE__) .'/../tests/feeds.test.inc');
/**
* Test Feed fast configuration.
*/
class FeedsExamplesFastFeedTestCase extends FeedsWebTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'features', 'feeds_fast_news', 'data', 'data_ui', 'views', 'views_ui');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes', 'administer data tables',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Feature: Fast feed'),
'description' => t('Test "Fast feed" default configuration <strong>Requires Data, Features and Views.</strong>'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
// Enable configuration and assert status.
$this->drupalGet('admin/build/data');
$this->assertText('feeds_data_feed_fast');
$this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
$this->assertText('Fast feed');
$this->assertText('There is no data in this table.');
// Create feed node.
$nid = $this->createFeedNode('feed_fast', NULL, '', 'feed_fast');
$this->assertText('Created 10 items.');
// Verify presence of aggregated items.
$this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
$this->assertText('Open Atrium Translation Workflow: Two Way Translation Updates');
$this->assertText('n a word, nothing. There has been a major improvement on this front. Now your translation');
$this->assertLink('http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating');
// Delete and re import.
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 0, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 0 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 0, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('Created 10 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 10, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('There are no new items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 10, 'Found correct number of items.');
}
}
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function feeds_import_ctools_plugin_api() {
list($module, $api) = func_get_args();
if ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => 1);
}
}
<?php
/**
* Implementation of hook_feeds_importer_default().
*/
function feeds_import_feeds_importer_default() {
$export = array();
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'node';
$feeds_importer->config = array(
'name' => 'Node import',
'description' => 'Import nodes from CSV file.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ',',
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'story',
'update_existing' => 1,
'expire' => '-1',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'body',
'target' => 'body',
'unique' => FALSE,
),
'2' => array(
'source' => 'published',
'target' => 'created',
'unique' => FALSE,
),
'3' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => 1,
),
),
'input_format' => 0,
'author' => 0,
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['node'] = $feeds_importer;
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'user';
$feeds_importer->config = array(
'name' => 'User import',
'description' => 'Import users from CSV file.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ',',
),
),
'processor' => array(
'plugin_key' => 'FeedsUserProcessor',
'config' => array(
'roles' => array(),
'update_existing' => FALSE,
'status' => 1,
'mappings' => array(
'0' => array(
'source' => 'name',
'target' => 'name',
'unique' => 0,
),
'1' => array(
'source' => 'mail',
'target' => 'mail',
'unique' => 1,
),
'2' => array(
'source' => 'created',
'target' => 'created',
'unique' => FALSE,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['user'] = $feeds_importer;
return $export;
}
core = "6.x"
dependencies[] = "feeds"
description = "An example of a node importer and a user importer."
features[ctools][] = "feeds:feeds_importer_default:1"
features[feeds_importer][] = "node"
features[feeds_importer][] = "user"
name = "Feeds Import"
package = "Feeds"
project = "Feeds"
<?php
include_once('feeds_import.features.inc');
...@@ -3,239 +3,22 @@ ...@@ -3,239 +3,22 @@
/** /**
* @file * @file
* Tests for default configurations. * Tests for feeds_import feature.
*/ */
// Require FeedsWebTestCase class definition. // Require FeedsWebTestCase class definition.
require_once(dirname(__FILE__) .'/../../tests/feeds.test.inc'); require_once(dirname(__FILE__) .'/../tests/feeds.test.inc');
/**
* Base class for default tests.
*/
class FeedsDefaultsTestCase extends FeedsWebTestCase {
/**
* Enable a default configuration and verify it.
*/
public function enable($ids) {
if (is_string($ids)) {
$ids = array($ids);
}
$edit = array();
foreach ($ids as $id) {
$edit[$id] = TRUE;
}
$this->drupalPost('admin/build/feeds', $edit, 'Save');
foreach ($ids as $id) {
$this->assertRaw('admin/build/feeds/edit/'. $id .'">Override', 'Enabled '. $id);
}
}
/**
* Disable a default configuration and verify it.
*/
public function disable($ids) {
if (is_string($ids)) {
$ids = array($ids);
}
$edit = array();
foreach ($ids as $id) {
$edit[$id] = FALSE;
}
$this->drupalPost('admin/build/feeds', $edit, 'Save');
foreach ($ids as $id) {
$this->assertNoRaw('admin/build/feeds/edit/'. $id .'">Override', 'Disabled '. $id);
}
}
}
/**
* Test Feed configuration.
*/
class FeedsDefaultsFeedTestCase extends FeedsDefaultsTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_defaults');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Defaults: Feed'),
'description' => t('Test "Feed" default configuration.'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
$this->enable('feed');
$nid = $this->createFeedNode('feed', NULL, '', 'feed');
// Assert results.
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 10, 'Found the correct number of feed item nodes in database.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 10, 'Found the correct number of records in feeds_node_item.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Open Atrium Translation Workflow: Two Way Translation Updates'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Week in DC Tech: October 5th Edition'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Integrating the Siteminder Access System in an Open Atrium-based Intranet'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Scaling the Open Atrium UI'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/05/week-dc-tech-october-5th-edition'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '974 at http://developmentseed.org'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '970 at http://developmentseed.org'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
// Remove all items
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes.');
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('Created 10 Feed item nodes.');
// Delete and assert all items gone.
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 0, 'Found the correct number of feed item nodes in database.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 0, 'Found the correct number of records in feeds_node_item.');
// Create a batch of nodes.
$this->createFeedNodes('feed', 10, 'feed');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 100, 'Imported 100 nodes.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 100, 'Found 100 records in feeds_node_item.');
// Disable the configuration.
$this->disable('feed');
$this->drupalGet('node/add');
$this->assertNoRaw('node/add/feed');
$this->assertNoText('node/add/feed-item');
}
}
/**
* Test Feed fast configuration.
*/
class FeedsDefaultsFastFeedTestCase extends FeedsDefaultsTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_defaults', 'data', 'data_ui', 'views', 'views_ui');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes', 'administer data tables',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Defaults: Fast feed'),
'description' => t('Test "Fast feed" default configuration <strong>Requires Data and Views.</strong>'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
// Enable configuration and assert status.
$this->enable('feed_fast');
$this->drupalGet('admin/build/data');
$this->assertText('feeds_data_feed_fast');
$this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
$this->assertText('Fast feed');
$this->assertText('There is no data in this table.');
// Create feed node.
$nid = $this->createFeedNode('feed_fast', NULL, '', 'feed_fast');
$this->assertText('Created 10 items.');
// Verify presence of aggregated items.
$this->drupalGet('admin/content/data/view/feeds_data_feed_fast');
$this->assertText('Open Atrium Translation Workflow: Two Way Translation Updates');
$this->assertText('n a word, nothing. There has been a major improvement on this front. Now your translation');
$this->assertLink('http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating');
// Delete and re import.
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 0, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 0 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 0, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('Created 10 items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 10, 'Found correct number of items.');
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('There are no new items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_data_feed_fast}"));
$this->assertEqual($count, 10, 'Found correct number of items.');
// Disable.
$this->disable('feed_fast');
$this->drupalGet('node/add');
$this->assertNoRaw('node/add/feed-fast');
}
}
/** /**
* Test Node import configuration. * Test Node import configuration.
*/ */
class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase { class FeedsExamplesNodeTestCase extends FeedsWebTestCase {
/** /**
* Set up test. * Set up test.
*/ */
public function setUp() { public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_defaults'); parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_import');
$this->drupalLogin( $this->drupalLogin(
$this->drupalCreateUser( $this->drupalCreateUser(
...@@ -251,7 +34,7 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase { ...@@ -251,7 +34,7 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase {
*/ */
public function getInfo() { public function getInfo() {
return array( return array(
'name' => t('Defaults: Node import'), 'name' => t('Feature: Node import'),
'description' => t('Test "Node import" default configuration.'), 'description' => t('Test "Node import" default configuration.'),
'group' => t('Feeds'), 'group' => t('Feeds'),
); );
...@@ -261,8 +44,6 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase { ...@@ -261,8 +44,6 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase {
* Run tests. * Run tests.
*/ */
public function test() { public function test() {
$this->enable('node');
// Import file. // Import file.
$this->importFile('node', $this->absolutePath() .'/tests/feeds/nodes.csv'); $this->importFile('node', $this->absolutePath() .'/tests/feeds/nodes.csv');
...@@ -332,18 +113,7 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase { ...@@ -332,18 +113,7 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase {
$this->drupalPost('import/node/import', array(), 'Import'); $this->drupalPost('import/node/import', array(), 'Import');
$this->assertText('Created 79 Story nodes.'); $this->assertText('Created 79 Story nodes.');
// Disable, nodes should be still present.
$this->disable('node');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 79, 'Found correct number of items.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'story' AND status = 1 AND uid = 0"));
$this->assertEqual($count, 79, 'Found correct number of items.');
// Do not filter on type intentionally. There shouldn't be more than 8 nodes total.
$count = db_result(db_query("SELECT COUNT(*) FROM {node_revisions}"));
$this->assertEqual($count, 79, 'Found correct number of items.');
// Import a tab separated file. // Import a tab separated file.
$this->enable('node');
$this->drupalPost('import/node/delete-items', array(), 'Delete'); $this->drupalPost('import/node/delete-items', array(), 'Delete');
$edit = array( $edit = array(
'files[feeds]' => $this->absolutePath() .'/tests/feeds/nodes.tsv', 'files[feeds]' => $this->absolutePath() .'/tests/feeds/nodes.tsv',
...@@ -351,79 +121,19 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase { ...@@ -351,79 +121,19 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase {
); );
$this->drupalPost('import/node', $edit, 'Import'); $this->drupalPost('import/node', $edit, 'Import');
$this->assertText('Created 8 Story nodes.'); $this->assertText('Created 8 Story nodes.');
// Disable before exiting test.
$this->disable('node');
}
}
/**
* Test OPML import configuration.
*/
class FeedsDefaultsOPMLTestCase extends FeedsDefaultsTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_defaults');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Defaults: OPML import'),
'description' => t('Test "OPML import" default configuration.'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
$this->enable('feed');
$this->enable('opml');
// Import OPML and assert.
$file = $this->generateOPML();
$this->importFile('opml', $file);
$this->assertText('Created 3 feed nodes.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_source}"));
$this->assertEqual($count, 4, 'Found correct number of items.');
// Import a feed and then delete all items from it.
$this->drupalPost('node/1/import', array(), 'Import');
$this->assertText('Created 10 Feed item nodes.');
$this->drupalPost('node/1/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes.');
// Disable.
$this->disable('feed');
$this->disable('opml');
} }
} }
/** /**
* Test User import configuration. * Test User import configuration.
*/ */
class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase { class FeedsExamplesUserTestCase extends FeedsWebTestCase {
/** /**
* Set up test. * Set up test.
*/ */
public function setUp() { public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_defaults'); parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_import');
$this->drupalLogin( $this->drupalLogin(
$this->drupalCreateUser( $this->drupalCreateUser(
...@@ -439,7 +149,7 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase { ...@@ -439,7 +149,7 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase {
*/ */
public function getInfo() { public function getInfo() {
return array( return array(
'name' => t('Defaults: User import'), 'name' => t('Feature: User import'),
'description' => t('Test "User import" default configuration.'), 'description' => t('Test "User import" default configuration.'),
'group' => t('Feeds'), 'group' => t('Feeds'),
); );
...@@ -449,8 +159,6 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase { ...@@ -449,8 +159,6 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase {
* Run tests. * Run tests.
*/ */
public function test() { public function test() {
$this->enable('user');
// Import CSV file. // Import CSV file.
$this->importFile('user', $this->absolutePath() .'/tests/feeds/users.csv'); $this->importFile('user', $this->absolutePath() .'/tests/feeds/users.csv');
...@@ -463,7 +171,5 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase { ...@@ -463,7 +171,5 @@ class FeedsDefaultsUserTestCase extends FeedsDefaultsTestCase {
$this->assertText('Fester'); $this->assertText('Fester');
$this->assertText('Gomez'); $this->assertText('Gomez');
$this->assertText('Pugsley'); $this->assertText('Pugsley');
$this->disable('user');
} }
} }
<?php <?php
// $Id$
/** /**
* @file * Implementation of hook_ctools_plugin_api().
* Default importer configurations for Feeds module.
*/ */
function feeds_news_ctools_plugin_api() {
require_once(dirname(__FILE__) .'/feeds_defaults.features.inc'); list($module, $api) = func_get_args();
if ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => 1);
}
}
/** /**
* Implementation of hook_node_info(). * Implementation of hook_node_info().
*/ */
function feeds_defaults_node_info() { function feeds_news_node_info() {
$items = array(); $items = array(
if (in_array('feed', feeds_enabled_importers())) { 'feed' => array(
$items['feed'] = array(
'name' => t('Feed'), 'name' => t('Feed'),
'module' => 'node', 'module' => 'node',
'description' => t('Subscribe to RSS or Atom feeds. Creates nodes of the content type "Feed item" from feed content.'), 'description' => t('Subscribe to RSS or Atom feeds. Creates nodes of the content type "Feed item" from feed content.'),
...@@ -22,9 +23,10 @@ function feeds_defaults_node_info() { ...@@ -22,9 +23,10 @@ function feeds_defaults_node_info() {
'title_label' => t('Title'), 'title_label' => t('Title'),
'has_body' => '1', 'has_body' => '1',
'body_label' => t('Body'), 'body_label' => t('Body'),
'locked' => TRUE, 'min_word_count' => '0',
); 'help' => '',
$items['feed_item'] = array( ),
'feed_item' => array(
'name' => t('Feed item'), 'name' => t('Feed item'),
'module' => 'node', 'module' => 'node',
'description' => t('This content type is being used for automatically aggregated content from feeds.'), 'description' => t('This content type is being used for automatically aggregated content from feeds.'),
...@@ -32,20 +34,18 @@ function feeds_defaults_node_info() { ...@@ -32,20 +34,18 @@ function feeds_defaults_node_info() {
'title_label' => t('Title'), 'title_label' => t('Title'),
'has_body' => '1', 'has_body' => '1',
'body_label' => t('Body'), 'body_label' => t('Body'),
'locked' => TRUE, 'min_word_count' => '0',
); 'help' => '',
} ),
if (in_array('feed_fast', feeds_enabled_importers())) { );
$items['feed_fast'] = array(
'name' => t('Fast feed'),
'module' => 'node',
'description' => t('Subscribe to RSS or Atom feeds. Create light weight database records from feed content.'),
'has_title' => '1',
'title_label' => t('Title'),
'has_body' => '1',
'body_label' => t('Body'),
'locked' => TRUE,
);
}
return $items; return $items;
} }
/**
* Implementation of hook_views_api().
*/
function feeds_news_views_api() {
return array(
'api' => '2',
);
}
<?php
/**
* Implementation of hook_feeds_importer_default().
*/
function feeds_news_feeds_importer_default() {
$export = array();
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed';
$feeds_importer->config = array(
'name' => 'Feed',
'description' => 'Import RSS or Atom feeds, create nodes from feed items.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'feed_item',
'update_existing' => 0,
'expire' => '-1',
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'description',
'target' => 'body',
'unique' => FALSE,
),
'2' => array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
'3' => array(
'source' => 'url',
'target' => 'url',
'unique' => TRUE,
),
'4' => array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
),
'input_format' => 0,
'author' => 0,
),
),
'content_type' => 'feed',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['feed'] = $feeds_importer;
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'opml';
$feeds_importer->config = array(
'name' => 'OPML import',
'description' => 'Import subscriptions from OPML files. Use together with "Feed" configuration.',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsOPMLParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsFeedNodeProcessor',
'config' => array(
'content_type' => 'feed',
'update_existing' => 0,
'mappings' => array(
'0' => array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
'1' => array(
'source' => 'xmlurl',
'target' => 'source',
'unique' => 1,
),
),
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
);
$export['opml'] = $feeds_importer;
return $export;
}
core = "6.x"
dependencies[] = "feeds"
dependencies[] = "views"
description = "A news aggregator built with feeds, creates nodes from imported feed items. With OPML import."
features[ctools][] = "feeds:feeds_importer_default:1"
features[feeds_importer][] = "feed"
features[feeds_importer][] = "opml"
features[node][] = "feed"
features[node][] = "feed_item"
features[views][] = "feeds_defaults_feed_items"
features[views_api][] = "api:2"
name = "Feeds News"
package = "Feeds"
project = "Feeds"
<?php
include_once('feeds_news.features.inc');
<?php
// $Id$
/**
* @file
* Tests for feeds_news feature.
*/
// Require FeedsWebTestCase class definition.
require_once(dirname(__FILE__) .'/../tests/feeds.test.inc');
/**
* Test Feed configuration.
*/
class FeedsExamplesFeedTestCase extends FeedsWebTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'features', 'feeds_news');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Feature: Feed'),
'description' => t('Test "Feed" default configuration. <strong>Requires Features.</strong>'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
$nid = $this->createFeedNode('feed', NULL, '', 'feed');
// Assert results.
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 10, 'Found the correct number of feed item nodes in database.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 10, 'Found the correct number of records in feeds_node_item.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Open Atrium Translation Workflow: Two Way Translation Updates'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Week in DC Tech: October 5th Edition'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Integrating the Siteminder Access System in an Open Atrium-based Intranet'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Scaling the Open Atrium UI'"));
$this->assertEqual($count, 1, 'Found title.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/05/week-dc-tech-october-5th-edition'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '974 at http://developmentseed.org'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '970 at http://developmentseed.org'"));
$this->assertEqual($count, 1, 'Found feed_node_item record.');
// Remove all items
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes.');
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('Created 10 Feed item nodes.');
// Delete and assert all items gone.
$this->drupalPost('node/'. $nid .'/delete-items', array(), 'Delete');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 0, 'Found the correct number of feed item nodes in database.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 0, 'Found the correct number of records in feeds_node_item.');
// Create a batch of nodes.
$this->createFeedNodes('feed', 10, 'feed');
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
$this->assertEqual($count, 100, 'Imported 100 nodes.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 100, 'Found 100 records in feeds_node_item.');
}
}
/**
* Test OPML import configuration.
*/
class FeedsExamplesOPMLTestCase extends FeedsWebTestCase {
/**
* Set up test.
*/
public function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'feeds_news');
$this->drupalLogin(
$this->drupalCreateUser(
array(
'administer feeds', 'administer nodes',
)
)
);
}
/**
* Describe this test.
*/
public function getInfo() {
return array(
'name' => t('Feature: OPML import'),
'description' => t('Test "OPML import" default configuration.'),
'group' => t('Feeds'),
);
}
/**
* Run tests.
*/
public function test() {
// Import OPML and assert.
$file = $this->generateOPML();
$this->importFile('opml', $file);
$this->assertText('Created 3 feed nodes.');
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_source}"));
$this->assertEqual($count, 4, 'Found correct number of items.');
// Import a feed and then delete all items from it.
$this->drupalPost('node/1/import', array(), 'Import');
$this->assertText('Created 10 Feed item nodes.');
$this->drupalPost('node/1/delete-items', array(), 'Delete');
$this->assertText('Deleted 10 nodes.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment