You are here

protected function FeedsTamperWebTestHelper::addTamperPlugin in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 tests/feeds_tamper.test \FeedsTamperWebTestHelper::addTamperPlugin()
4 calls to FeedsTamperWebTestHelper::addTamperPlugin()
FeedsTamperCSVTestCase::test in tests/feeds_tamper.test
FeedsTamperCSVTestCase::testRewrite in tests/feeds_tamper.test
FeedsTamperWebTestCase::testBasic in tests/feeds_tamper.test
FeedsTamperWebTestCase::testCopyPlugin in tests/feeds_tamper.test
Integration tests for the copy plugin.
1 method overrides FeedsTamperWebTestHelper::addTamperPlugin()
FeedsTamperUIWebTestCase::addTamperPlugin in feeds_tamper_ui/tests/feeds_tamper_ui.test

File

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

Class

FeedsTamperWebTestHelper
Base class for Feeds Tamper tests.

Code

protected 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 (!strlen($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 = :id", array(
    ':id' => $plugin->id,
  ));

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

  // Check for only 1 item.
  $this
    ->assertIdentical($result
    ->rowCount(), 1);
  return $id;
}