You are here

function Braintree_TransactionTest::testCloneTransaction in Commerce Braintree 7

File

braintree_php/tests/integration/TransactionTest.php, line 7

Class

Braintree_TransactionTest

Code

function testCloneTransaction() {
  $result = Braintree_Transaction::sale(array(
    'amount' => '100.00',
    'orderId' => '123',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/2011',
    ),
    'customer' => array(
      'firstName' => 'Dan',
    ),
    'billing' => array(
      'firstName' => 'Carl',
    ),
    'shipping' => array(
      'firstName' => 'Andrew',
    ),
  ));
  $this
    ->assertTrue($result->success);
  $transaction = $result->transaction;
  $cloneResult = Braintree_Transaction::cloneTransaction($transaction->id, array(
    'amount' => '123.45',
    'options' => array(
      'submitForSettlement' => false,
    ),
  ));
  Braintree_TestHelper::assertPrintable($cloneResult);
  $this
    ->assertTrue($cloneResult->success);
  $cloneTransaction = $cloneResult->transaction;
  $this
    ->assertEquals('Dan', $cloneTransaction->customerDetails->firstName);
  $this
    ->assertEquals('Carl', $cloneTransaction->billingDetails->firstName);
  $this
    ->assertEquals('Andrew', $cloneTransaction->shippingDetails->firstName);
  $this
    ->assertEquals('510510******5100', $cloneTransaction->creditCardDetails->maskedNumber);
  $this
    ->assertEquals('authorized', $cloneTransaction->status);
}