function CommerceRecurringTestCase::testCommerceRecurringCronOrderCreationWithQuantity in Commerce Recurring Framework 7.2
Test recurring orders with quantity.
File
- tests/
commerce_recurring.test, line 707 - Unit tests for the commerce recurring module.
Class
- CommerceRecurringTestCase
- @file Unit tests for the commerce recurring module.
Code
function testCommerceRecurringCronOrderCreationWithQuantity() {
// Create a recurring entity.
$product = $this
->createRecurringProduct();
$line_item = commerce_cart_product_add_by_id($product->product_id, 2, TRUE, $this->customer->uid);
$recurring_entity = $this
->createRecurringEntity($product, 2);
$initial_order = commerce_order_load($line_item->order_id);
$initial_order->commerce_customer_billing = (array) $this
->createDummyCustomerProfile('billing', $this->customer->uid);
$initial_order->status = 'completed';
commerce_order_save($initial_order);
commerce_cart_order_ids_reset();
// Run cron.
drupal_cron_run();
// Check if the order has been correctly created and it's linked to the
// recurring entity.
$recurring_entities = entity_load('commerce_recurring', array(
$recurring_entity->id,
), array(), TRUE);
$recurring_entity = reset($recurring_entities);
$recurring_wrapper = entity_metadata_wrapper('commerce_recurring', $recurring_entity);
// The order is the second one now.
$order_wrapper = $recurring_wrapper->commerce_recurring_order
->get(1);
$order = $order_wrapper
->value();
$this
->assertTrue(isset($order), t('New order has been created for the recurring entity'));
$this
->assertEqual($order_wrapper->commerce_line_items
->get(0)->quantity
->value(), 2, t('Order line item with the recurring product has quantity 2.'));
}