Index: feeds.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/feeds.info,v
retrieving revision 1.7.2.5
diff -u -p -r1.7.2.5 feeds.info
--- feeds.info	1 Nov 2010 16:58:21 -0000	1.7.2.5
+++ feeds.info	19 Feb 2011 18:33:08 -0000
@@ -9,12 +9,12 @@ files[] = feeds.install
 files[] = includes/FeedsConfigurable.inc
 files[] = includes/FeedsImporter.inc
 files[] = includes/FeedsSource.inc
-files[] = tests/feeds.test.inc
+files[] = tests/feeds.test
 files[] = tests/feeds_date_time.test
 files[] = tests/feeds_mapper_date.test
 files[] = tests/feeds_mapper_field.test
 files[] = tests/feeds_mapper_file.test
-files[] = tests/feeds_mapper_test.inc
+files[] = tests/feeds_mapper.test
 files[] = tests/feeds_fetcher_file.test
 files[] = tests/feeds_processor_node.test
 files[] = tests/feeds_processor_term.test
Index: feeds_ui/tests/feeds_ui.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/feeds_ui/tests/feeds_ui.test,v
retrieving revision 1.9.2.1
diff -u -p -r1.9.2.1 feeds_ui.test
--- feeds_ui/tests/feeds_ui.test	30 Sep 2010 19:16:27 -0000	1.9.2.1
+++ feeds_ui/tests/feeds_ui.test	19 Feb 2011 18:33:09 -0000
@@ -6,9 +6,6 @@
  * Tests for Feeds Admin UI module.
  */
 
-// Require FeedsWebTestCase class definition.
-require_once(dirname(__FILE__) .'/../../tests/feeds.test.inc');
-
 /**
  * Test basic Feeds UI functionality.
  */
@@ -136,4 +133,4 @@ class FeedsUIUserInterfaceTestCase exten
 
     // @todo Refreshing/deleting feed items. Needs to live in feeds.test
   }
-}
\ No newline at end of file
+}
Index: tests/feeds.test
===================================================================
RCS file: tests/feeds.test
diff -N tests/feeds.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/feeds.test	19 Feb 2011 18:33:09 -0000
@@ -0,0 +1,424 @@
+<?php
+// $Id: feeds.test.inc,v 1.19.2.7 2010/12/22 00:49:22 alexb Exp $
+
+/**
+ * @file
+ * Common functionality for all Feeds tests.
+ */
+
+/**
+ * Test basic Data API functionality.
+ */
+class FeedsWebTestCase extends DrupalWebTestCase {
+  protected $profile = 'testing';
+
+  /**
+   * This override of setUp requires that modules are passed as an array, also
+   * please don't pass duplicates of what is defined below!
+   */
+  function setUp($add_modules = array()) {
+    // We ensure the taxonomy module is enabled first to prevent issues later
+    // on where plugins aren't available.
+    parent::setUp(array('taxonomy'));
+    $modules = array(
+      'image',
+      'file',
+      'field',
+      'field_ui',
+      'ctools',
+      'job_scheduler',
+      'feeds',
+      'feeds_ui',
+    );
+    foreach ($add_modules as $m) {
+      $modules[] =  $m;
+    }
+    module_enable($modules, TRUE);
+    $this->resetAll();
+
+    // Add text formats Directly.
+    $filtered_html_format = array(
+      'format' => 'filtered_html',
+      'name' => 'Filtered HTML',
+      'weight' => 0,
+      'filters' => array(
+        // URL filter.
+        'filter_url' => array(
+          'weight' => 0,
+          'status' => 1,
+        ),
+        // HTML filter.
+        'filter_html' => array(
+          'weight' => 1,
+          'status' => 1,
+        ),
+        // Line break filter.
+        'filter_autop' => array(
+          'weight' => 2,
+          'status' => 1,
+        ),
+        // HTML corrector filter.
+        'filter_htmlcorrector' => array(
+          'weight' => 10,
+          'status' => 1,
+        ),
+      ),
+    );
+    $filtered_html_format = (object) $filtered_html_format;
+    filter_format_save($filtered_html_format);
+
+    // Create a user and log her in for node type config.
+    $this->admin_user = $this->drupalCreateUser(array(
+      'access content',
+      'administer site configuration',
+      'administer feeds',
+      'administer nodes',
+      'administer content types',
+      'bypass node access',
+    ));
+    $this->drupalLogin($this->admin_user);
+
+    $types = array(
+      array(
+        'type' => 'page',
+        'name' => 'Basic page',
+        'node_options[status]' => 1,
+        'node_options[promote]' => 0,
+      ),
+      array(
+        'type' => 'article',
+        'name' => 'Article',
+        'node_options[status]' => 1,
+        'node_options[promote]' => 1,
+      ),
+    );
+    foreach ($types as $type) {
+      $this->drupalPost('admin/structure/types/add', $type, 'Save content type');
+      $this->assertText("The content type " . $type['name'] . " has been added.");
+    }
+  }
+
+  /**
+   * Absolute path to Drupal root.
+   */
+  public function absolute() {
+    return realpath(getcwd());
+  }
+
+  /**
+   * Get the absolute directory path of the feeds module.
+   */
+  public function absolutePath() {
+    return  $this->absolute() .'/'. drupal_get_path('module', 'feeds');
+  }
+
+  /**
+   * Generate an OPML test feed.
+   *
+   * The purpose of this function is to create a dynamic OPML feed that points
+   * to feeds included in this test.
+   */
+  public function generateOPML() {
+    $path = $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/';
+
+  $output =
+'<?xml version="1.0" encoding="utf-8"?>
+<opml version="1.1">
+<head>
+    <title>Feeds test OPML</title>
+    <dateCreated>Fri, 16 Oct 2009 02:53:17 GMT</dateCreated>
+    <ownerName></ownerName>
+</head>
+<body>
+  <outline text="Feeds test group" >
+    <outline title="Development Seed - Technological Solutions for Progressive Organizations" text="" xmlUrl="'. $path .'developmentseed.rss2" type="rss" />
+    <outline title="Magyar Nemzet Online - H’rek" text="" xmlUrl="'. $path .'feed_without_guid.rss2" type="rss" />
+    <outline title="Drupal planet" text="" type="rss" xmlUrl="'. $path .'drupalplanet.rss2" />
+  </outline>
+</body>
+</opml>';
+
+    // UTF 8 encode output string and write it to disk
+    $output = utf8_encode($output);
+    $filename = file_default_scheme() . '://test-opml-'. $this->randomName() . '.opml';
+
+    $filename = file_unmanaged_save_data($output, $filename);
+    return $filename;
+  }
+
+  /**
+   * Create an importer configuration.
+   *
+   * @param $name
+   *   The natural name of the feed.
+   * @param $id
+   *   The persistent id of the feed.
+   * @param $edit
+   *   Optional array that defines the basic settings for the feed in a format
+   *   that can be posted to the feed's basic settings form.
+   */
+  public function createImporterConfiguration($name = 'Syndication', $id = 'syndication') {
+    // Create new feed configuration.
+    $this->drupalGet('admin/structure/feeds');
+    $this->clickLink('New importer');
+    $edit = array(
+      'name' => $name,
+      'id' => $id,
+    );
+    $this->drupalPost('admin/structure/feeds/create', $edit, 'Create');
+
+    // Assert message and presence of default plugins.
+    $this->assertText('Your configuration has been created with default settings.');
+    $this->assertPlugins($id, 'FeedsHTTPFetcher', 'FeedsSyndicationParser', 'FeedsNodeProcessor');
+    // Per default attach to page content type.
+    $this->setSettings($id, NULL, array('content_type' => 'page'));
+  }
+
+  /**
+   * Choose a plugin for a importer configuration and assert it.
+   *
+   * @param $id
+   *   The importer configuration's id.
+   * @param $plugin_key
+   *   The key string of the plugin to choose (one of the keys defined in
+   *   feeds_feeds_plugins()).
+   */
+  public function setPlugin($id, $plugin_key) {
+    if ($type = FeedsPlugin::typeOf($plugin_key)) {
+      $edit = array(
+        'plugin_key' => $plugin_key,
+      );
+      $this->drupalPost("admin/structure/feeds/edit/$id/$type", $edit, 'Save');
+
+      // Assert actual configuration.
+      $config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $id))->fetchField());
+      $this->assertEqual($config[$type]['plugin_key'], $plugin_key, 'Verified correct '. $type .' ('. $plugin_key .').');
+    }
+  }
+
+  /**
+   * Set importer or plugin settings.
+   *
+   * @param $id
+   *   The importer configuration's id.
+   * @param $plugin
+   *   The plugin (class) name, or NULL to set importer's settings
+   * @param $settings
+   *   The settings to set.
+   */
+  public function setSettings($id, $plugin, $settings) {
+    $this->drupalPost('admin/structure/feeds/edit/'. $id .'/settings/'. $plugin, $settings, 'Save');
+    $this->assertText('Your changes have been saved.');
+  }
+
+  /**
+   * 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
+   *   The node id of the node created.
+   */
+  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_select('feeds_importer', 'f')
+        ->condition('f.id', $id, '=')
+        ->fields('f', array('config'))
+        ->execute();
+      $config = unserialize($result->fetchField());
+      $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.
+    $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()->fetch();
+    $config = unserialize($source->config);
+    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
+    return $nid;
+  }
+
+  /**
+   * Edit the configuration of a feed node to test update behavior.
+   *
+   * @param $nid
+   *   The nid to edit.
+   * @param $feed_url
+   *   The new (absolute) feed URL to use.
+   * @param $title
+   *   Optional parameter to change title of feed node.
+   */
+  public function editFeedNode($nid, $feed_url, $title = '') {
+    $edit = array(
+      'title' => $title,
+      'feeds[FeedsHTTPFetcher][source]' => $feed_url,
+    );
+    // Check that the update was saved.
+    $this->drupalPost('node/' . $nid . '/edit', $edit, 'Save');
+    $this->assertText('has been updated.');
+
+    // Check that the URL was updated in the feeds_source table.
+    //$source = db_query("SELECT * FROM {feeds_source} WHERE feed_nid = :nid", array(':nid' => $nid))->fetch();
+    $source = db_select('feeds_source', 's')
+      ->condition('s.feed_nid', $nid, '=')
+      ->fields('s', array('config'))
+      ->execute()->fetch();
+    $config = unserialize($source->config);
+    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
+  }
+
+  /**
+   * Batch create a variable amount of feed nodes. All will have the
+   * same URL configured.
+   *
+   * @return
+   *   An array of node ids of the nodes created.
+   */
+  public function createFeedNodes($id = 'syndication', $num = 20, $content_type = NULL) {
+    $nids = array();
+    for ($i = 0; $i < $num; $i++) {
+      $nids[] = $this->createFeedNode($id, NULL, $this->randomName(), $content_type);
+    }
+    return $nids;
+  }
+
+  /**
+   * Import a URL through the import form. Assumes FeedsHTTPFetcher in place.
+   */
+  public function importURL($id, $feed_url = NULL) {
+    if (empty($feed_url)) {
+      $feed_url = $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/developmentseed.rss2';
+    }
+    $edit = array(
+      'feeds[FeedsHTTPFetcher][source]' => $feed_url,
+    );
+    $nid = $this->drupalPost('import/'. $id, $edit, 'Import');
+
+    // Check whether feed got recorded in feeds_source table.
+    $this->assertEqual(1, db_query("SELECT COUNT(*) FROM {feeds_source} WHERE id = :id AND feed_nid = 0", array(':id' => $id))->fetchField());
+    $source = db_query("SELECT * FROM {feeds_source} WHERE id = :id AND feed_nid = 0",  array(':id' => $id))->fetch();
+    $config = unserialize($source->config);
+    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
+
+    // Check whether feed got properly added to scheduler.
+    $this->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField());
+    // There must be only one entry for callback 'expire' - no matter what the feed_nid is.
+    $this->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND name = 'feeds_importer_expire' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField());
+  }
+
+  /**
+   * Import a file through the import form. Assumes FeedsFileFetcher in place.
+   */
+  public function importFile($id, $file) {
+
+    $this->assertTrue(file_exists($file), 'Source file exists');
+    $edit = array(
+      'files[feeds]' => $file,
+    );
+    $this->drupalPost('import/'. $id, $edit, 'Import');
+  }
+
+  /**
+   * Assert a feeds configuration's plugins.
+   *
+   * @deprecated:
+   *   Use setPlugin() instead.
+   *
+   * @todo Refactor users of assertPlugin() and make them use setPugin() instead.
+   */
+  public function assertPlugins($id, $fetcher, $parser, $processor) {
+    // Assert actual configuration.
+    $config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $id))->fetchField());
+
+    $this->assertEqual($config['fetcher']['plugin_key'], $fetcher, 'Correct fetcher');
+    $this->assertEqual($config['parser']['plugin_key'], $parser, 'Correct parser');
+    $this->assertEqual($config['processor']['plugin_key'], $processor, 'Correct processor');
+  }
+
+  /**
+   * Add mappings to a given configuration.
+   *
+   * @param $mappings
+   *   An array of mapping arrays. Each mapping array must have a source and
+   *   an target key and can have a unique key.
+   *
+   * @see FeedsRSStoDataTest class.
+   */
+  public function addMappings($id, $mappings) {
+
+    $path = 'admin/structure/feeds/edit/'. $id .'/mapping';
+
+    // Iterate through all mappings and add the via the form.
+    foreach ($mappings as $i => $mapping) {
+
+      // Get unique flag and unset it - otherwise drupalPost will complain that
+      // there is no form element named "unique".
+      $unique = !empty($mapping['unique']);
+      unset($mapping['unique']);
+      $this->drupalPost($path, $mapping, t('Add'));
+
+      // If unique was set, set the last mapping's unique flag.
+      if ($unique) {
+        $edit = array(
+          'unique_flags['. $i .']' => 1,
+        );
+        $this->drupalPost($path, $edit, t('Save'));
+      }
+    }
+  }
+
+  /**
+   * Helper function, retrieves node id from a URL.
+   */
+  public function getNid($url) {
+    $matches = array();
+    preg_match('/node\/(\d+?)$/', $url, $matches);
+    $nid = $matches[1];
+    if (!is_numeric($nid)) {
+      $this->error(t('Could not find node id, found @nid instead.', array('@nid' => $nid)));
+    }
+    return $nid;
+  }
+
+  /**
+   * Copies a directory.
+   */
+  public function copyDir($source, $dest) {
+    $result = file_prepare_directory($dest, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+    foreach (@scandir($source) as $file) {
+      if (is_file("$source/$file")) {
+        $file = file_unmanaged_copy("$source/$file", "$dest/$file");
+      }
+    }
+  }
+}
Index: tests/feeds.test.inc
===================================================================
RCS file: tests/feeds.test.inc
diff -N tests/feeds.test.inc
--- tests/feeds.test.inc	22 Dec 2010 00:49:22 -0000	1.19.2.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,424 +0,0 @@
-<?php
-// $Id: feeds.test.inc,v 1.19.2.7 2010/12/22 00:49:22 alexb Exp $
-
-/**
- * @file
- * Common functionality for all Feeds tests.
- */
-
-/**
- * Test basic Data API functionality.
- */
-class FeedsWebTestCase extends DrupalWebTestCase {
-  protected $profile = 'testing';
-
-  /**
-   * This override of setUp requires that modules are passed as an array, also
-   * please don't pass duplicates of what is defined below!
-   */
-  function setUp($add_modules = array()) {
-    // We ensure the taxonomy module is enabled first to prevent issues later
-    // on where plugins aren't available.
-    parent::setUp(array('taxonomy'));
-    $modules = array(
-      'image',
-      'file',
-      'field',
-      'field_ui',
-      'ctools',
-      'job_scheduler',
-      'feeds',
-      'feeds_ui',
-    );
-    foreach ($add_modules as $m) {
-      $modules[] =  $m;
-    }
-    module_enable($modules, TRUE);
-    $this->resetAll();
-
-    // Add text formats Directly.
-    $filtered_html_format = array(
-      'format' => 'filtered_html',
-      'name' => 'Filtered HTML',
-      'weight' => 0,
-      'filters' => array(
-        // URL filter.
-        'filter_url' => array(
-          'weight' => 0,
-          'status' => 1,
-        ),
-        // HTML filter.
-        'filter_html' => array(
-          'weight' => 1,
-          'status' => 1,
-        ),
-        // Line break filter.
-        'filter_autop' => array(
-          'weight' => 2,
-          'status' => 1,
-        ),
-        // HTML corrector filter.
-        'filter_htmlcorrector' => array(
-          'weight' => 10,
-          'status' => 1,
-        ),
-      ),
-    );
-    $filtered_html_format = (object) $filtered_html_format;
-    filter_format_save($filtered_html_format);
-
-    // Create a user and log her in for node type config.
-    $this->admin_user = $this->drupalCreateUser(array(
-      'access content',
-      'administer site configuration',
-      'administer feeds',
-      'administer nodes',
-      'administer content types',
-      'bypass node access',
-    ));
-    $this->drupalLogin($this->admin_user);
-
-    $types = array(
-      array(
-        'type' => 'page',
-        'name' => 'Basic page',
-        'node_options[status]' => 1,
-        'node_options[promote]' => 0,
-      ),
-      array(
-        'type' => 'article',
-        'name' => 'Article',
-        'node_options[status]' => 1,
-        'node_options[promote]' => 1,
-      ),
-    );
-    foreach ($types as $type) {
-      $this->drupalPost('admin/structure/types/add', $type, 'Save content type');
-      $this->assertText("The content type " . $type['name'] . " has been added.");
-    }
-  }
-
-  /**
-   * Absolute path to Drupal root.
-   */
-  public function absolute() {
-    return realpath(getcwd());
-  }
-
-  /**
-   * Get the absolute directory path of the feeds module.
-   */
-  public function absolutePath() {
-    return  $this->absolute() .'/'. drupal_get_path('module', 'feeds');
-  }
-
-  /**
-   * Generate an OPML test feed.
-   *
-   * The purpose of this function is to create a dynamic OPML feed that points
-   * to feeds included in this test.
-   */
-  public function generateOPML() {
-    $path = $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/';
-
-  $output =
-'<?xml version="1.0" encoding="utf-8"?>
-<opml version="1.1">
-<head>
-    <title>Feeds test OPML</title>
-    <dateCreated>Fri, 16 Oct 2009 02:53:17 GMT</dateCreated>
-    <ownerName></ownerName>
-</head>
-<body>
-  <outline text="Feeds test group" >
-    <outline title="Development Seed - Technological Solutions for Progressive Organizations" text="" xmlUrl="'. $path .'developmentseed.rss2" type="rss" />
-    <outline title="Magyar Nemzet Online - H’rek" text="" xmlUrl="'. $path .'feed_without_guid.rss2" type="rss" />
-    <outline title="Drupal planet" text="" type="rss" xmlUrl="'. $path .'drupalplanet.rss2" />
-  </outline>
-</body>
-</opml>';
-
-    // UTF 8 encode output string and write it to disk
-    $output = utf8_encode($output);
-    $filename = file_default_scheme() . '://test-opml-'. $this->randomName() . '.opml';
-
-    $filename = file_unmanaged_save_data($output, $filename);
-    return $filename;
-  }
-
-  /**
-   * Create an importer configuration.
-   *
-   * @param $name
-   *   The natural name of the feed.
-   * @param $id
-   *   The persistent id of the feed.
-   * @param $edit
-   *   Optional array that defines the basic settings for the feed in a format
-   *   that can be posted to the feed's basic settings form.
-   */
-  public function createImporterConfiguration($name = 'Syndication', $id = 'syndication') {
-    // Create new feed configuration.
-    $this->drupalGet('admin/structure/feeds');
-    $this->clickLink('New importer');
-    $edit = array(
-      'name' => $name,
-      'id' => $id,
-    );
-    $this->drupalPost('admin/structure/feeds/create', $edit, 'Create');
-
-    // Assert message and presence of default plugins.
-    $this->assertText('Your configuration has been created with default settings.');
-    $this->assertPlugins($id, 'FeedsHTTPFetcher', 'FeedsSyndicationParser', 'FeedsNodeProcessor');
-    // Per default attach to page content type.
-    $this->setSettings($id, NULL, array('content_type' => 'page'));
-  }
-
-  /**
-   * Choose a plugin for a importer configuration and assert it.
-   *
-   * @param $id
-   *   The importer configuration's id.
-   * @param $plugin_key
-   *   The key string of the plugin to choose (one of the keys defined in
-   *   feeds_feeds_plugins()).
-   */
-  public function setPlugin($id, $plugin_key) {
-    if ($type = FeedsPlugin::typeOf($plugin_key)) {
-      $edit = array(
-        'plugin_key' => $plugin_key,
-      );
-      $this->drupalPost("admin/structure/feeds/edit/$id/$type", $edit, 'Save');
-
-      // Assert actual configuration.
-      $config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $id))->fetchField());
-      $this->assertEqual($config[$type]['plugin_key'], $plugin_key, 'Verified correct '. $type .' ('. $plugin_key .').');
-    }
-  }
-
-  /**
-   * Set importer or plugin settings.
-   *
-   * @param $id
-   *   The importer configuration's id.
-   * @param $plugin
-   *   The plugin (class) name, or NULL to set importer's settings
-   * @param $settings
-   *   The settings to set.
-   */
-  public function setSettings($id, $plugin, $settings) {
-    $this->drupalPost('admin/structure/feeds/edit/'. $id .'/settings/'. $plugin, $settings, 'Save');
-    $this->assertText('Your changes have been saved.');
-  }
-
-  /**
-   * 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
-   *   The node id of the node created.
-   */
-  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_select('feeds_importer', 'f')
-        ->condition('f.id', $id, '=')
-        ->fields('f', array('config'))
-        ->execute();
-      $config = unserialize($result->fetchField());
-      $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.
-    $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()->fetch();
-    $config = unserialize($source->config);
-    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
-    return $nid;
-  }
-
-  /**
-   * Edit the configuration of a feed node to test update behavior.
-   *
-   * @param $nid
-   *   The nid to edit.
-   * @param $feed_url
-   *   The new (absolute) feed URL to use.
-   * @param $title
-   *   Optional parameter to change title of feed node.
-   */
-  public function editFeedNode($nid, $feed_url, $title = '') {
-    $edit = array(
-      'title' => $title,
-      'feeds[FeedsHTTPFetcher][source]' => $feed_url,
-    );
-    // Check that the update was saved.
-    $this->drupalPost('node/' . $nid . '/edit', $edit, 'Save');
-    $this->assertText('has been updated.');
-
-    // Check that the URL was updated in the feeds_source table.
-    //$source = db_query("SELECT * FROM {feeds_source} WHERE feed_nid = :nid", array(':nid' => $nid))->fetch();
-    $source = db_select('feeds_source', 's')
-      ->condition('s.feed_nid', $nid, '=')
-      ->fields('s', array('config'))
-      ->execute()->fetch();
-    $config = unserialize($source->config);
-    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
-  }
-
-  /**
-   * Batch create a variable amount of feed nodes. All will have the
-   * same URL configured.
-   *
-   * @return
-   *   An array of node ids of the nodes created.
-   */
-  public function createFeedNodes($id = 'syndication', $num = 20, $content_type = NULL) {
-    $nids = array();
-    for ($i = 0; $i < $num; $i++) {
-      $nids[] = $this->createFeedNode($id, NULL, $this->randomName(), $content_type);
-    }
-    return $nids;
-  }
-
-  /**
-   * Import a URL through the import form. Assumes FeedsHTTPFetcher in place.
-   */
-  public function importURL($id, $feed_url = NULL) {
-    if (empty($feed_url)) {
-      $feed_url = $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/developmentseed.rss2';
-    }
-    $edit = array(
-      'feeds[FeedsHTTPFetcher][source]' => $feed_url,
-    );
-    $nid = $this->drupalPost('import/'. $id, $edit, 'Import');
-
-    // Check whether feed got recorded in feeds_source table.
-    $this->assertEqual(1, db_query("SELECT COUNT(*) FROM {feeds_source} WHERE id = :id AND feed_nid = 0", array(':id' => $id))->fetchField());
-    $source = db_query("SELECT * FROM {feeds_source} WHERE id = :id AND feed_nid = 0",  array(':id' => $id))->fetch();
-    $config = unserialize($source->config);
-    $this->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));
-
-    // Check whether feed got properly added to scheduler.
-    $this->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField());
-    // There must be only one entry for callback 'expire' - no matter what the feed_nid is.
-    $this->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND name = 'feeds_importer_expire' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField());
-  }
-
-  /**
-   * Import a file through the import form. Assumes FeedsFileFetcher in place.
-   */
-  public function importFile($id, $file) {
-
-    $this->assertTrue(file_exists($file), 'Source file exists');
-    $edit = array(
-      'files[feeds]' => $file,
-    );
-    $this->drupalPost('import/'. $id, $edit, 'Import');
-  }
-
-  /**
-   * Assert a feeds configuration's plugins.
-   *
-   * @deprecated:
-   *   Use setPlugin() instead.
-   *
-   * @todo Refactor users of assertPlugin() and make them use setPugin() instead.
-   */
-  public function assertPlugins($id, $fetcher, $parser, $processor) {
-    // Assert actual configuration.
-    $config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $id))->fetchField());
-
-    $this->assertEqual($config['fetcher']['plugin_key'], $fetcher, 'Correct fetcher');
-    $this->assertEqual($config['parser']['plugin_key'], $parser, 'Correct parser');
-    $this->assertEqual($config['processor']['plugin_key'], $processor, 'Correct processor');
-  }
-
-  /**
-   * Add mappings to a given configuration.
-   *
-   * @param $mappings
-   *   An array of mapping arrays. Each mapping array must have a source and
-   *   an target key and can have a unique key.
-   *
-   * @see FeedsRSStoDataTest class.
-   */
-  public function addMappings($id, $mappings) {
-
-    $path = 'admin/structure/feeds/edit/'. $id .'/mapping';
-
-    // Iterate through all mappings and add the via the form.
-    foreach ($mappings as $i => $mapping) {
-
-      // Get unique flag and unset it - otherwise drupalPost will complain that
-      // there is no form element named "unique".
-      $unique = !empty($mapping['unique']);
-      unset($mapping['unique']);
-      $this->drupalPost($path, $mapping, t('Add'));
-
-      // If unique was set, set the last mapping's unique flag.
-      if ($unique) {
-        $edit = array(
-          'unique_flags['. $i .']' => 1,
-        );
-        $this->drupalPost($path, $edit, t('Save'));
-      }
-    }
-  }
-
-  /**
-   * Helper function, retrieves node id from a URL.
-   */
-  public function getNid($url) {
-    $matches = array();
-    preg_match('/node\/(\d+?)$/', $url, $matches);
-    $nid = $matches[1];
-    if (!is_numeric($nid)) {
-      $this->error(t('Could not find node id, found @nid instead.', array('@nid' => $nid)));
-    }
-    return $nid;
-  }
-
-  /**
-   * Copies a directory.
-   */
-  public function copyDir($source, $dest) {
-    $result = file_prepare_directory($dest, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-    foreach (@scandir($source) as $file) {
-      if (is_file("$source/$file")) {
-        $file = file_unmanaged_copy("$source/$file", "$dest/$file");
-      }
-    }
-  }
-}
Index: tests/feeds_mapper.test
===================================================================
RCS file: tests/feeds_mapper.test
diff -N tests/feeds_mapper.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/feeds_mapper.test	19 Feb 2011 18:33:09 -0000
@@ -0,0 +1,163 @@
+<?php
+// $Id: feeds_mapper_test.inc,v 1.2.4.2 2010/11/01 16:58:21 tristanoneil Exp $
+
+/**
+ * @file
+ * Helper class with auxiliary functions for feeds mapper module tests.
+ */
+
+/**
+ * Base class for implementing Feeds Mapper test cases.
+ */
+class FeedsMapperTestCase extends FeedsWebTestCase {
+
+  // A lookup map to select the widget for each field type.
+  private static $field_widgets = array(
+    'date' => 'date_text',
+    'datestamp' => 'date_text',
+    'datetime' => 'date_text',
+    'number_decimal' => 'number',
+    'email' => 'email_textfield',
+    'emimage' => 'emimage_textfields',
+    'emaudio' => 'emaudio_textfields',
+    'filefield' => 'filefield_widget',
+    'image' => 'imagefield_widget',
+    'link_field' => 'link_field',
+    'number_float' => 'number',
+    'number_integer' => 'number',
+    'nodereference' => 'nodereference_select',
+    'text' => 'text_textfield',
+    'userreference' => 'userreference_select',
+   );
+
+  /**
+   * Assert that a form field for the given field with the given value
+   * exists in the current form.
+   *
+   * @param $field_name
+   *   The name of the field.
+   * @param $value
+   *   The (raw) value expected for the field.
+   * @param $index
+   *   The index of the field (for q multi-valued field).
+   *
+   * @see FeedsMapperTestCase::getFormFieldsNames()
+   * @see FeedsMapperTestCase::getFormFieldsValues()
+   */
+  protected function assertNodeFieldValue($field_name, $value, $index = 0) {
+    $names = $this->getFormFieldsNames($field_name, $index);
+    $values = $this->getFormFieldsValues($field_name, $value);
+    foreach($names as $k => $name){
+      $value = $values[$k];
+      $this->assertFieldByName($name, $value, t('Found form field %name for %field_name with the expected value.', array('%name' => $name, '%field_name' => $field_name)));
+    }
+  }
+
+  /**
+   * Returns the form fields names for a given CCK field. Default implementation
+   * provides support for a single form field with the following name pattern
+   * <code>"field_{$field_name}[{$index}][value]"</code>
+   *
+   * @param $field_name
+   *   The name of the CCK field.
+   * @param $index
+   *   The index of the field (for q multi-valued field).
+   *
+   * @return
+   *   An array of form field names.
+   */
+  protected function getFormFieldsNames($field_name, $index) {
+    return array("field_{$field_name}[und][{$index}][value]");
+  }
+
+  /**
+   * Returns the form fields values for a given CCK field. Default implementation
+   * returns a single element array with $value casted to a string.
+   *
+   * @param $field_name
+   *   The name of the CCK field.
+   * @param $value
+   *   The (raw) value expected for the CCK field.
+   * @return An array of form field values.
+   */
+  protected function getFormFieldsValues($field_name, $value) {
+    return array((string)$value);
+  }
+
+  /**
+   * Create a new content-type, and add a field to it. Mostly copied from
+   * cck/tests/content.crud.test ContentUICrud::testAddFieldUI
+   *
+   * @param $typename
+   *   (Optional) the name of the content-type to create, defaults to a random name.
+   * @param $fields
+   *   (Optional) an keyed array of $field_name => $field_type used to add additional
+   *   fields to the new content type.
+   *
+   * @return
+   *   The name of the new typename.
+   */
+  final protected function createContentType($typename = NULL, $fields = array()) {
+    if ($typename == NULL) {
+      $typename = strtolower($this->randomName());
+    }
+
+    // Create the content type.
+    $edit = array(
+      'type' => $typename,
+      'name' => $typename,
+    );
+    $this->drupalPost('admin/structure/types/add', $edit, 'Save content type');
+    $this->assertText('The content type ' . $typename . ' has been added', 'Content type created');
+
+    $admin_type_url = 'admin/structure/types/manage/'. str_replace('_', '-', $typename);
+
+    // Create the fields
+    foreach ($fields as $field_name => $options) {
+      if(is_string($options)) {
+        $options = array('type' => $options);
+      }
+      $field_type = isset($options['type']) ? $options['type'] : 'text';
+      $field_widget = isset($options['widget']) ? $options['widget'] : $this->selectFieldWidget($field_name, $field_type);
+      $this->assertTrue($field_widget !== NULL, "Field type $field_type supported");
+      $label = $field_name . '_' . $field_type . '_label';
+      $edit = array(
+        'fields[_add_new_field][label]' => $label,
+        'fields[_add_new_field][field_name]' => $field_name,
+        'fields[_add_new_field][type]' => $field_type,
+        'fields[_add_new_field][widget_type]' => $field_widget,
+      );
+      $this->drupalPost($admin_type_url . '/fields', $edit, 'Save');
+
+      // (Default) Configure the field.
+      $edit = isset($options['settings']) ? $options['settings'] : array();
+      $this->drupalPost(NULL, $edit, 'Save field settings');
+      $this->assertText('Updated field ' . $label);
+    }
+
+    return $typename;
+  }
+
+  /**
+   * Select the widget for the field. Default implementation provides widgets
+   * for Date, Number, Text, Node reference, User reference, Email, Emfield,
+   * Filefield, Image, and Link.
+   *
+   * Extracted as a method to allow test implementations to add widgets for
+   * the tested CCK field type(s). $field_name allow to test the same
+   * field type with different widget (is this useful ?)
+   *
+   * @param $field_name
+   *   The name of the field.
+   * @param $field_type
+   *   The CCK type of the field.
+   *
+   * @return
+   *   The widget for this field, or NULL if the field_type is not
+   *   supported by this test class.
+   */
+  protected function selectFieldWidget($field_name, $field_type) {
+    $field_widgets = FeedsMapperTestCase::$field_widgets;
+    return isset($field_widgets[$field_type]) ? $field_widgets[$field_type] : NULL;
+  }
+}
Index: tests/feeds_mapper_link.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/tests/feeds_mapper_link.test,v
retrieving revision 1.5.4.4
diff -u -p -r1.5.4.4 feeds_mapper_link.test
--- tests/feeds_mapper_link.test	1 Nov 2010 19:08:59 -0000	1.5.4.4
+++ tests/feeds_mapper_link.test	19 Feb 2011 18:33:09 -0000
@@ -6,8 +6,6 @@
  * Test case for CCK link mapper mappers/date.inc.
  */
 
-require_once(drupal_get_path('module', 'feeds') . '/tests/feeds_mapper_test.inc');
-
 /**
  * Class for testing Feeds <em>link</em> mapper.
  */
Index: tests/feeds_mapper_test.inc
===================================================================
RCS file: tests/feeds_mapper_test.inc
diff -N tests/feeds_mapper_test.inc
--- tests/feeds_mapper_test.inc	1 Nov 2010 16:58:21 -0000	1.2.4.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,166 +0,0 @@
-<?php
-// $Id: feeds_mapper_test.inc,v 1.2.4.2 2010/11/01 16:58:21 tristanoneil Exp $
-
-/**
- * @file
- * Helper class with auxiliary functions for feeds mapper module tests.
- */
-
-// Require FeedsWebTestCase class definition.
-require_once(dirname(__FILE__) .'/feeds.test.inc');
-
-/**
- * Base class for implementing Feeds Mapper test cases.
- */
-class FeedsMapperTestCase extends FeedsWebTestCase {
-
-  // A lookup map to select the widget for each field type.
-  private static $field_widgets = array(
-    'date' => 'date_text',
-    'datestamp' => 'date_text',
-    'datetime' => 'date_text',
-    'number_decimal' => 'number',
-    'email' => 'email_textfield',
-    'emimage' => 'emimage_textfields',
-    'emaudio' => 'emaudio_textfields',
-    'filefield' => 'filefield_widget',
-    'image' => 'imagefield_widget',
-    'link_field' => 'link_field',
-    'number_float' => 'number',
-    'number_integer' => 'number',
-    'nodereference' => 'nodereference_select',
-    'text' => 'text_textfield',
-    'userreference' => 'userreference_select',
-   );
-
-  /**
-   * Assert that a form field for the given field with the given value
-   * exists in the current form.
-   *
-   * @param $field_name
-   *   The name of the field.
-   * @param $value
-   *   The (raw) value expected for the field.
-   * @param $index
-   *   The index of the field (for q multi-valued field).
-   *
-   * @see FeedsMapperTestCase::getFormFieldsNames()
-   * @see FeedsMapperTestCase::getFormFieldsValues()
-   */
-  protected function assertNodeFieldValue($field_name, $value, $index = 0) {
-    $names = $this->getFormFieldsNames($field_name, $index);
-    $values = $this->getFormFieldsValues($field_name, $value);
-    foreach($names as $k => $name){
-      $value = $values[$k];
-      $this->assertFieldByName($name, $value, t('Found form field %name for %field_name with the expected value.', array('%name' => $name, '%field_name' => $field_name)));
-    }
-  }
-
-  /**
-   * Returns the form fields names for a given CCK field. Default implementation
-   * provides support for a single form field with the following name pattern
-   * <code>"field_{$field_name}[{$index}][value]"</code>
-   *
-   * @param $field_name
-   *   The name of the CCK field.
-   * @param $index
-   *   The index of the field (for q multi-valued field).
-   *
-   * @return
-   *   An array of form field names.
-   */
-  protected function getFormFieldsNames($field_name, $index) {
-    return array("field_{$field_name}[und][{$index}][value]");
-  }
-
-  /**
-   * Returns the form fields values for a given CCK field. Default implementation
-   * returns a single element array with $value casted to a string.
-   *
-   * @param $field_name
-   *   The name of the CCK field.
-   * @param $value
-   *   The (raw) value expected for the CCK field.
-   * @return An array of form field values.
-   */
-  protected function getFormFieldsValues($field_name, $value) {
-    return array((string)$value);
-  }
-
-  /**
-   * Create a new content-type, and add a field to it. Mostly copied from
-   * cck/tests/content.crud.test ContentUICrud::testAddFieldUI
-   *
-   * @param $typename
-   *   (Optional) the name of the content-type to create, defaults to a random name.
-   * @param $fields
-   *   (Optional) an keyed array of $field_name => $field_type used to add additional
-   *   fields to the new content type.
-   *
-   * @return
-   *   The name of the new typename.
-   */
-  final protected function createContentType($typename = NULL, $fields = array()) {
-    if ($typename == NULL) {
-      $typename = strtolower($this->randomName());
-    }
-
-    // Create the content type.
-    $edit = array(
-      'type' => $typename,
-      'name' => $typename,
-    );
-    $this->drupalPost('admin/structure/types/add', $edit, 'Save content type');
-    $this->assertText('The content type ' . $typename . ' has been added', 'Content type created');
-
-    $admin_type_url = 'admin/structure/types/manage/'. str_replace('_', '-', $typename);
-
-    // Create the fields
-    foreach ($fields as $field_name => $options) {
-      if(is_string($options)) {
-        $options = array('type' => $options);
-      }
-      $field_type = isset($options['type']) ? $options['type'] : 'text';
-      $field_widget = isset($options['widget']) ? $options['widget'] : $this->selectFieldWidget($field_name, $field_type);
-      $this->assertTrue($field_widget !== NULL, "Field type $field_type supported");
-      $label = $field_name . '_' . $field_type . '_label';
-      $edit = array(
-        'fields[_add_new_field][label]' => $label,
-        'fields[_add_new_field][field_name]' => $field_name,
-        'fields[_add_new_field][type]' => $field_type,
-        'fields[_add_new_field][widget_type]' => $field_widget,
-      );
-      $this->drupalPost($admin_type_url . '/fields', $edit, 'Save');
-
-      // (Default) Configure the field.
-      $edit = isset($options['settings']) ? $options['settings'] : array();
-      $this->drupalPost(NULL, $edit, 'Save field settings');
-      $this->assertText('Updated field ' . $label);
-    }
-
-    return $typename;
-  }
-
-  /**
-   * Select the widget for the field. Default implementation provides widgets
-   * for Date, Number, Text, Node reference, User reference, Email, Emfield,
-   * Filefield, Image, and Link.
-   *
-   * Extracted as a method to allow test implementations to add widgets for
-   * the tested CCK field type(s). $field_name allow to test the same
-   * field type with different widget (is this useful ?)
-   *
-   * @param $field_name
-   *   The name of the field.
-   * @param $field_type
-   *   The CCK type of the field.
-   *
-   * @return
-   *   The widget for this field, or NULL if the field_type is not
-   *   supported by this test class.
-   */
-  protected function selectFieldWidget($field_name, $field_type) {
-    $field_widgets = FeedsMapperTestCase::$field_widgets;
-    return isset($field_widgets[$field_type]) ? $field_widgets[$field_type] : NULL;
-  }
-}
