You are here

public function FeedsTamperKeyWordFilterTestCase::executeKey in Feeds Tamper 7

Same name and namespace in other branches
  1. 6 tests/feeds_tamper_plugins.test \FeedsTamperKeyWordFilterTestCase::executeKey()
1 call to FeedsTamperKeyWordFilterTestCase::executeKey()
FeedsTamperKeyWordFilterTestCase::test in tests/feeds_tamper_plugins.test

File

tests/feeds_tamper_plugins.test, line 708
Unit tests for feeds tamper plugins.

Class

FeedsTamperKeyWordFilterTestCase
Tests for keyword_filter.inc

Code

public function executeKey($item, $output, $element_key, $settings) {
  $result = new stdClass();
  $result->items = array();
  $result->items[] = $item;
  $this
    ->validate($settings);
  $this
    ->callback($result, 0, NULL, $result->items[0][$element_key], $settings);
  $this
    ->assertEqual($result->items, $output);

  // Test multi valued.
  foreach ($item as $key => $value) {
    $item[$key] = array(
      $value,
    );
  }
  if (!empty($output)) {
    foreach ($output[0] as $key => $value) {
      $output[0][$key] = array(
        $value,
      );
    }
  }
  $result = new stdClass();
  $result->items = array();
  $result->items[] = $item;
  $this
    ->callback($result, 0, NULL, $result->items[0][$element_key], $settings);
  $this
    ->assertEqual($result->items, $output);
}