You are here

function PayPalPaymentIPNControllerTest::testProcess in PayPal for Payment 7

Test process().

File

paypal_payment_ipn/tests/PayPalPaymentIPNControllerTest.test, line 123
Contains \PayPalPaymentIPNControllerTest.

Class

PayPalPaymentIPNControllerTest
Tests PayPalPaymentIPNController functionality.

Code

function testProcess() {
  $payment_method = $this
    ->paymentMethodCreate(2, payment_method_controller_load('PayPalPaymentIPNTestPaymentMethodController'));
  entity_save('payment_method', $payment_method);
  $payment = $this
    ->paymentCreate(2, $payment_method);
  entity_save('payment', $payment);
  $original_payment_status = $payment
    ->getStatus()->status;
  $ipn_variables = $this
    ->mockIPNVariables($payment->pid);
  PayPalPaymentIPNController::process($ipn_variables);
  $payment = entity_load_single('payment', $payment->pid);
  $this
    ->assertNotEqual($original_payment_status, $payment
    ->getStatus()->status);

  // Test processing the same IPN again.
  $original_payment_status = $payment
    ->getStatus()->status;
  $ipn_variables = $this
    ->mockIPNVariables($payment->pid);
  PayPalPaymentIPNController::process($ipn_variables);
  $payment = entity_load_single('payment', $payment->pid);
  $this
    ->assertEqual($original_payment_status, $payment
    ->getStatus()->status);
}