You are here

function ucRecurringAPITestCase::testRecurringAdminFunctions in UC Recurring Payments and Subscriptions 6.2

Same name and namespace in other branches
  1. 7.2 uc_recurring.test \ucRecurringAPITestCase::testRecurringAdminFunctions()

Test administrator functions.

File

./uc_recurring.test, line 226
UC Recurring simpletest

Class

ucRecurringAPITestCase
Test the recurring API.

Code

function testRecurringAdminFunctions() {
  $this
    ->drupalLogin($this->user_recurring_admin);
  $this
    ->drupalGet('admin/store/orders/recurring');

  // TODO: check admin settings form
  // create two products with recurring features
  $product = $this
    ->createProduct();
  $recurring_feature = $this
    ->createRecurringFeature($product->nid);
  $this
    ->drupalLogout();

  // create an order
  $order_id = $this
    ->placeOrderWithRecurringFee($product);
  if ($order_id) {
    $order = uc_order_load($order_id);
    $fees = uc_recurring_get_fees($order);
    $fee = $fees[0];
    $this
      ->drupalLogin($this->user_recurring_admin);

    // charge fee
    $this
      ->drupalGet('admin/store/orders/recurring');
    $this
      ->clickLink(t('charge'));
    $this
      ->drupalPost(NULL, array(), t('Process Renewal'));
    $this
      ->assertEqual($order_id + 1, $this
      ->lastCreatedOrderId(), t('Order renewed after canceled.'));

    // edit fee
    $this
      ->drupalGet('admin/store/orders/recurring');
    $this
      ->clickLink(t('edit'));

    // TODO: check we can edit fields and that they are updated in db
    // cancel fee
    $this
      ->drupalGet('admin/store/orders/recurring');
    $this
      ->clickLink(t('cancel'));
    $this
      ->drupalPost(NULL, array(), t('Yes, I want to cancel the subscription'));

    // attempt to renew
    $last_order_id = $this
      ->lastCreatedOrderId();
    $this
      ->processRecurringFee($fee->rfid, 1);
    $this
      ->assertEqual($last_order_id, $this
      ->lastCreatedOrderId(), t('Order did not renew after canceled.'));
    $this
      ->drupalLogout();
  }
}