protected function UbercartQuoteTestCase::createQuote in Ubercart 7.3
Creates a flat rate shipping quote with optional conditions.
Parameters
array $edit: Data to use to create shipping quote, same format as the values submitted from the add flatrate method form.
bool $condition: If specified, a RulesAnd component defining the conditions to apply for this method.
2 calls to UbercartQuoteTestCase::createQuote()
- UbercartQuoteTestCase::testNoQuote in shipping/
uc_quote/ tests/ uc_quote.test - Verifies shipping pane is hidden when there are no shippable items.
- UbercartQuoteTestCase::testQuote in shipping/
uc_quote/ tests/ uc_quote.test - Tests basic flatrate shipping quote functionality.
File
- shipping/
uc_quote/ tests/ uc_quote.test, line 48 - Ubercart Shipping Quote Tests.
Class
- UbercartQuoteTestCase
- SimpleTests for Ubercart Shipping Quotes.
Code
protected function createQuote(array $edit = array(), $condition = FALSE) {
$edit += array(
'title' => $this
->randomName(8),
'label' => $this
->randomName(8),
'base_rate' => mt_rand(1, 10),
'product_rate' => mt_rand(1, 10),
);
$form_state = array(
'values' => $edit,
);
drupal_form_submit('uc_flatrate_admin_method_edit_form', $form_state);
$method = db_query("SELECT * FROM {uc_flatrate_methods} WHERE mid = :mid", array(
':mid' => $form_state['values']['mid'],
))
->fetchObject();
if ($condition) {
$name = 'get_quote_from_flatrate_' . $method->mid;
$condition['LABEL'] = $edit['label'] . ' conditions';
$oldconfig = rules_config_load($name);
$newconfig = rules_import(array(
$name => $condition,
));
$newconfig->id = $oldconfig->id;
unset($newconfig->is_new);
$newconfig->status = ENTITY_CUSTOM;
$newconfig
->save();
entity_flush_caches();
}
$this
->assertTrue($method->base_rate == $edit['base_rate'], 'Flatrate quote was created successfully');
return $method;
}