You are here

function FeedsTamperConditionalUnitTests::executeConditional in Feeds Tamper Conditional 7

1 call to FeedsTamperConditionalUnitTests::executeConditional()
FeedsTamperConditionalUnitTests::test in tests/feeds_tamper_conditional.test

File

tests/feeds_tamper_conditional.test, line 150
Unit tests for Feeds Tamper Conditional module.

Class

FeedsTamperConditionalUnitTests
@file Unit tests for Feeds Tamper Conditional module.

Code

function executeConditional($field_name, $compare_field_name, $compare_field_value, $value_to_compare, $operator, $pass_message, $expect_remove = TRUE, $negate = FALSE) {
  $this->result->items[$this->item_key][$field_name] = 'FirstName';
  $this->result->items[$this->item_key][$compare_field_name] = $compare_field_value;
  $this->settings['value'] = $value_to_compare;
  $this->settings['operator'] = $operator;
  $this->settings['conditional_field'] = $compare_field_name;
  $this->settings['negate'] = $negate;

  /*
      // Debug.
      $this->pass('$this->result: ' . var_export($this->result, TRUE));
      $this->pass('$this->item_key: ' . var_export($this->item_key, TRUE));
      $this->pass('$field_name: ' . var_export($field_name, TRUE));
      $this->pass('$compare_field_value: ' . var_export($compare_field_value, TRUE));
      $this->pass('$this->settings: ' . var_export($this->settings, TRUE));
  */

  // Run the conditional through the main feeds_tamper_conditional_callback() function.
  $this
    ->callback($this->result, $this->item_key, $field_name, $compare_field_value, $this->settings);
  if ($expect_remove) {
    $is_pass = !isset($this->result->items[$this->item_key][$field_name]);
  }
  else {

    // Expect value will be retained.
    $is_pass = isset($this->result->items[$this->item_key][$field_name]);
  }
  $this
    ->assertTrue($is_pass, $pass_message);
  $this->item_key++;
}