You are here

protected function UCXFTestCase::checkValuesInDatabase in Extra Fields Checkout Pane 7

Same name and namespace in other branches
  1. 6.2 uc_extra_fields_pane.test \UCXFTestCase::checkValuesInDatabase()

Test if these values appear in the database.

Parameters

array $values: An array of ucxf values, grouped by field name.

int $order_id: The Ubercart order ID

int $type: The value element type

Return value

void

2 calls to UCXFTestCase::checkValuesInDatabase()
UCXFOrderTestCase::testOrder in ./uc_extra_fields_pane.test
Test the order administration.
UCXFTestCase::checkout in ./uc_extra_fields_pane.test
Overrides UbercartTestHelper::checkout().

File

./uc_extra_fields_pane.test, line 310
Automated tests for Extra Fields Pane

Class

UCXFTestCase
Base class for all Extra Fields Pane test cases.

Code

protected function checkValuesInDatabase($values, $order_id, $type) {
  $saved_values = UCXF_Value::load_list($order_id, $type);
  foreach ($values as $db_name => $value) {
    $field_id = UCXF_FieldList::getFieldByName($db_name)->id;
    $value_type = UCXF_FieldList::getFieldByName($db_name)
      ->get_value_type();
    $message = t('Value for field %field correctly saved with value %value', array(
      '%field' => $this
        ->getFieldname($db_name),
      '%value' => $value,
    ));
    if (!isset($saved_values[$field_id])) {
      $this
        ->fail($message);
    }
    else {
      $this
        ->assertEqual($saved_values[$field_id]
        ->getValue(), $value, $message . ' (' . check_plain($saved_values[$field_id]
        ->getValue()) . ')');
    }
  }
}