You are here

public function FeedsTamperWebTestHelper::addTamperPlugin in Feeds Tamper 6

Same name and namespace in other branches
  1. 7 tests/feeds_tamper.test \FeedsTamperWebTestHelper::addTamperPlugin()
2 calls to FeedsTamperWebTestHelper::addTamperPlugin()
FeedsTamperCSVTestCase::test in tests/feeds_tamper.test
FeedsTamperWebTestCase::testBasic in tests/feeds_tamper.test
1 method overrides FeedsTamperWebTestHelper::addTamperPlugin()
FeedsTamperUIWebTestCase::addTamperPlugin in feeds_tamper_ui/tests/feeds_tamper_ui.test

File

tests/feeds_tamper.test, line 39
Tests for feeds_tamper.module.

Class

FeedsTamperWebTestHelper
Base class for Feeds Tamper tests.

Code

public function addTamperPlugin($importer_id, $source, $plugin_id, $settings = array(), $description = '', $id = NULL) {
  $plugin_info = feeds_tamper_get_plugin($plugin_id);
  if ($plugin_info['validate']) {
    $plugin_info['validate']($settings);
  }
  $plugin = feeds_tamper_new_instance();
  if (!empty($settings)) {
    $plugin->settings = $settings;
  }
  $plugin->importer = $importer_id;
  $plugin->source = $source;
  $plugin->plugin_id = $plugin_id;
  if (!isset($description)) {
    $description = $this
      ->randomString(255);
  }
  if (!isset($id)) {
    $id = $this
      ->randomName();
  }
  $plugin->id = $id;
  $plugin->description = $description;
  $this
    ->assertEqual(SAVED_NEW, feeds_tamper_save_instance($plugin));
  $result = db_query("SELECT * FROM {feeds_tamper} WHERE id = '%s'", $plugin->id);

  // test that default weight is added.
  $instance = db_fetch_object($result);
  $this
    ->assertTrue($instance->weight >= 0);
  $this
    ->assertEqual($instance->description, $description);

  // Check for only 1 item.
  $result = db_result(db_query("SELECT COUNT(*) FROM {feeds_tamper} WHERE id = '%s'", $plugin->id));
  $this
    ->assertIdentical((int) $result, 1);
  return $id;
}