You are here

function Braintree_TransactionTest::testCloneWithValidations in Commerce Braintree 7

File

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

Class

Braintree_TransactionTest

Code

function testCloneWithValidations() {
  $result = Braintree_Transaction::credit(array(
    'amount' => '100.00',
    'creditCard' => array(
      'number' => '5105105105105100',
      'expirationDate' => '05/2011',
    ),
  ));
  $this
    ->assertTrue($result->success);
  $transaction = $result->transaction;
  $cloneResult = Braintree_Transaction::cloneTransaction($transaction->id, array(
    'amount' => '123.45',
  ));
  $this
    ->assertFalse($cloneResult->success);
  $baseErrors = $cloneResult->errors
    ->forKey('transaction')
    ->onAttribute('base');
  $this
    ->assertEquals(Braintree_Error_Codes::TRANSACTION_CANNOT_CLONE_CREDIT, $baseErrors[0]->code);
}