protected function UCXFTestCase::checkTokens in Extra Fields Checkout Pane 7
Same name and namespace in other branches
- 6.2 uc_extra_fields_pane.test \UCXFTestCase::checkTokens()
Test if tokens are properly generated.
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
1 call to UCXFTestCase::checkTokens()
- UCXFTestCase::checkout in ./
uc_extra_fields_pane.test - Overrides UbercartTestHelper::checkout().
File
- ./
uc_extra_fields_pane.test, line 337 - Automated tests for Extra Fields Pane
Class
- UCXFTestCase
- Base class for all Extra Fields Pane test cases.
Code
protected function checkTokens($values, $order_id, $type) {
$order = uc_order_load($order_id);
foreach ($values as $db_name => $value) {
$field = UCXF_FieldList::getFieldByName($db_name);
// Generate token name.
$token_name = '';
switch ($type) {
case UCXF_Value::UCXF_VALUE_ORDER_DELIVERY:
$token_name = 'uc_order:uc-addresses-shipping-address:' . $field->db_name;
break;
case UCXF_Value::UCXF_VALUE_ORDER_BILLING:
$token_name = 'uc_order:uc-addresses-billing-address:' . $field->db_name;
break;
}
// Test if generated token value is equal to expected output.
$text = '[' . $token_name . ']';
$token_value = token_replace($text, array(
'uc_order' => $order,
));
$this
->assertEqual($field
->output_value($value), $token_value, t('The token for %field is properly generated.', array(
'%field' => $field->db_name,
)));
}
}