You are here

public function FeedsTamperUIWebTestCase::addTamperPlugin in Feeds Tamper 6

Same name and namespace in other branches
  1. 8.2 legacy/feeds_tamper_ui/tests/feeds_tamper_ui.test \FeedsTamperUIWebTestCase::addTamperPlugin()
  2. 7 feeds_tamper_ui/tests/feeds_tamper_ui.test \FeedsTamperUIWebTestCase::addTamperPlugin()

Overrides FeedsTamperWebTestHelper::addTamperPlugin

2 calls to FeedsTamperUIWebTestCase::addTamperPlugin()
FeedsTamperUIWebTestCase::testBasic in feeds_tamper_ui/tests/feeds_tamper_ui.test
FeedsTamperUIWebTestCase::_testCSV in feeds_tamper_ui/tests/feeds_tamper_ui.test

File

feeds_tamper_ui/tests/feeds_tamper_ui.test, line 198
Tests for feeds_tamper_ui.module.

Class

FeedsTamperUIWebTestCase
Test Feeds Tamper UI.

Code

public function addTamperPlugin($importer_id, $source, $plugin_id, $settings = array(), $description = NULL, $id = NULL) {
  $plugin = feeds_tamper_get_plugin($plugin_id);
  $default_description = !empty($plugin['default description']) ? $plugin['default description'] : $plugin['name'];
  $default_id = feeds_tamper_make_machine($default_description);
  $url = FEEDS_TAMPER_UI_BASE . '/add/' . $importer_id . '/' . bin2hex($source);
  $this
    ->drupalPost($url, array(
    'plugin_id' => $plugin_id,
  ), 'Choose');

  // Check that default values were added to form.
  $this
    ->assertFieldByName('id', $default_id);
  $this
    ->assertFieldByName('description', $default_description);

  // Set settings.
  $edit = array(
    'plugin_id' => $plugin_id,
  );
  if (!empty($description)) {
    $edit['description'] = $description;
  }
  if (!empty($id)) {
    $edit['id'] = $id;
  }
  $this
    ->drupalPost(NULL, $edit + $settings, 'Add');
  $description = !empty($description) ? $description : $default_description;
  $id = !empty($id) ? $id : $default_id;
  $id = $importer_id . '-' . feeds_tamper_make_machine($source) . '-' . $id;
  $instance = feeds_tamper_load_instance($id);
  $source_name = feeds_tamper_ui_source_name($instance);
  $this
    ->assertText('Plugin ' . $description . ' was successfully added to ' . $source_name . '.');
  return $id;
}