public function MerciBaseTestCase::createDummyLineItem in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Create a dummy order in a given status.
Parameters
$uid: ID of the user that owns the order.
$products: Array of products that are going to be added to the order: keys are product ids, values are the quantity of products to add.
$status: Status of the order
Return value
A commerce order object in the given status.
2 calls to MerciBaseTestCase::createDummyLineItem()
- MerciBaseTesterTestCase::testTestCreateDummyLineItem in merci_core/
tests/ merci_base.test - Test the createDummyReservation function.
- MerciSandboxTestCase::testTestTest in merci_core/
tests/ merci_base.test - Sandbox for test development
File
- merci_core/
tests/ merci_base.test, line 359 - Defines abstract base test class for the Merci module tests.
Class
- MerciBaseTestCase
- Abstract class for Merci testing. All Merci tests should extend this class.
Code
public function createDummyLineItem($uid = 1, $products = array(), $dates = array()) {
// If there aren't any products to add to the order, create one.
if (empty($products)) {
$product = $this
->createDummyProduct('PROD-01', 'Product One', -1, 'USD', $uid);
$products[$product->product_id] = rand(1, 10);
}
if (empty($dates)) {
$dates = array(
'value' => date('Y-m-d H:i:s'),
'value2' => date('Y-m-d H:i:s', time() + 3600),
'timezone' => 'America/Los Angeles',
'timezone_db' => 'UTC',
'data_type' => 'datetime',
);
}
$default_values = array(
'type' => 'merci_line_item',
);
$line_item = entity_create('merci_line_item', $default_values);
$wrapper = entity_metadata_wrapper('merci_line_item', $line_item);
// TODO support for multiple products.
reset($products);
$wrapper->{MERCI_RESOURCE_REFERENCE}
->set(key($products));
$wrapper->{MERCI_CHECKOUT_DATES}
->set($dates);
$wrapper
->save();
$this
->verbose(print_r($wrapper
->value(), TRUE));
return $wrapper
->value();
}