You are here

function CommerceRecurringTestCase::testCommerceRecurringCancelRecurringFromOrder in Commerce Recurring Framework 7.2

Test if the recurring entity is disabled when cancelling an order.

File

tests/commerce_recurring.test, line 778
Unit tests for the commerce recurring module.

Class

CommerceRecurringTestCase
@file Unit tests for the commerce recurring module.

Code

function testCommerceRecurringCancelRecurringFromOrder() {

  // Create a recurring entity.
  $product = $this
    ->createRecurringProduct();
  $line_item = commerce_cart_product_add_by_id($product->product_id, 1, TRUE, $this->customer->uid);
  $start_date = new DateObject('2010-01-01');
  $due_date = new DateObject();
  $due_date
    ->sub(new DateInterval('P1D'));
  $recurring_entity = $this
    ->createRecurringEntity($product, 1, $start_date, $due_date);
  $order = commerce_order_load($line_item->order_id);
  $order->commerce_customer_billing = (array) $this
    ->createDummyCustomerProfile('billing', $this->customer->uid);
  $order->status = 'completed';
  commerce_order_save($order);
  $order->status = 'canceled';
  commerce_order_save($order);
  $recurring_entity = entity_load_single('commerce_recurring', $recurring_entity->id);
  $this
    ->assertEqual($recurring_entity->status, 0, t('Recurring entity has been disabled when the order is canceled'));
}