You are here

function PaymentCommerceDeleteOrderWebTestCase::assertCreateAndDeleteOrderAndPayment in Payment for Drupal Commerce 7

Same name and namespace in other branches
  1. 7.2 tests/PaymentCommerceDeleteOrderWebTestCase.test \PaymentCommerceDeleteOrderWebTestCase::assertCreateAndDeleteOrderAndPayment()

Creates an order, transaction and Payment, and then deletes them.

Return value

integer The PID of the Payment that was created and deleted.

1 call to PaymentCommerceDeleteOrderWebTestCase::assertCreateAndDeleteOrderAndPayment()
PaymentCommerceDeleteOrderWebTestCase::testDeleteOrder in tests/PaymentCommerceDeleteOrderWebTestCase.test

File

tests/PaymentCommerceDeleteOrderWebTestCase.test, line 48

Class

PaymentCommerceDeleteOrderWebTestCase

Code

function assertCreateAndDeleteOrderAndPayment() {
  $order = commerce_order_new();
  commerce_order_save($order);
  $this
    ->assertTrue($order->order_id > 0);
  $payment_method = $this
    ->paymentMethodCreate(0, payment_method_controller_load('PaymentMethodBasicController'));
  $payment = payment_commerce_payment_create($order, $payment_method->pmid);
  entity_save('payment', $payment);
  $this
    ->assertTrue($payment->pid > 0);
  $transaction = commerce_payment_transaction_new('payment_commerce_' . $payment->method->pmid, $payment->context_data['order_id']);
  payment_commerce_transaction_fill($transaction, $payment);
  commerce_payment_transaction_save($transaction);
  payment_commerce_transaction_save($payment->pid, $transaction->transaction_id);
  commerce_order_delete($order->order_id);
  $this
    ->assertFalse(commerce_order_load($order->order_id));
  return $payment->pid;
}